A rururutata type sequence is defined as a sequence that can be written as $r + r + r + t + t$ ($+$ means concatenation) using non-empty sequences $r$ and $t$.
You are given an integer sequence $S = (S_1, S_2, \dots, S_N)$ of length $N$. There are $Q$ queries, which you must process in order.
In each query, integers $L$ and $R$ are given. Determine whether there exists a rururutata type sequence as a contiguous subarray of $(S_L, S_{L+1}, \dots, S_R)$.
Input
The input is given in the following format:
N S1 S2 ... SN Q query1 query2 : queryQ
Each query is given in the following format:
L R
Constraints
- $1 \le N \le 5 \times 10^5$
- $1 \le S_i \le N$ ($1 \le i \le N$)
- $1 \le Q \le 5 \times 10^5$
- $1 \le L \le R \le N$
- All input values are integers.
Output
Print $Q$ lines.
On the $i$-th line, print Yes if a rururutata type sequence exists for the $i$-th query, and No otherwise.
Example
Input 1
17 3 3 3 2 2 2 4 3 4 3 4 3 2 2 2 2 2 5 1 5 4 12 2 6 8 15 13 17
Output 1
Yes Yes No No Yes
Note
For the first query, $(S_1, S_2, S_3, S_4, S_5) = (3, 3, 3, 2, 2)$ is a rururutata type sequence. The condition is satisfied by taking $r = (3)$ and $t = (2)$.
For the second query, among $(S_4, S_5, \dots, S_{12})$, the contiguous subarray $(S_4, S_5, \dots, S_{10}) = (2, 2, 2, 4, 3, 4, 3)$ is a rururutata type sequence. The condition is satisfied by taking $r = (2)$ and $t = (4, 3)$.
For the third query, $(3, 3, 2, 2, 2)$ is not a rururutata type sequence, and it clearly does not contain any shorter rururutata type sequence either.
For the fourth query, note that $(3, 3, 3, 2, 2)$ is not a contiguous subarray.
For the fifth query, note that it is allowed for $r$ and $t$ to be the same.