Solve the programming task below in a Python markdown code block.
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef Aditi keeps changing the flavours of her dishes and she wants to analyse feedback from her customers in order to improve her performance. The customers visiting Aditi's restaurant can rate the food online and Aditi knows an aggregated rating for each day. As she is busy cooking, you should perform the data analysis.

You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$ of distinct integers denoting the customers' feedback during $N$ days. You should process $Q$ queries. In each query, you are given two integers $L$ and $R$. Consider any contiguous subsequence $A_{p}, A_{p+1}, \ldots, A_{q}$, where $L ≤ p < q ≤ R$; let's call it a *maximal increasing subsequence* if the following conditions hold:
$A_{p} < A_{p+1} \ldots < A_{q}$
if $p > L$, then $A_{p} < A_{p-1}$
if $q < R$, then $A_{q} > A_{q+1}$

Similarly, let's define a *maximal decreasing subsequence*. You should find out if the number of maximal increasing subsequences is equal to the number of maximal decreasing subsequences (with $L ≤ p < q ≤ R$).

For example, if $A = (10, 20, 30, 5)$, we can see that the only maximal increasing subsequence of this sequence (for $L=1$ and $R=N$) is $(10, 20, 30)$, since $(10, 20)$ does not satisfy the third condition and $(20, 30)$ does not satisfy the second condition, and there is only one maximal decreasing subsequence $(30, 5)$.

------  Input ------
The first line of the input contains two space-separated integers $N$ and $Q$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.
$Q$ lines follow. Each of these lines contains two space-separated integers $L$ and $R$ describing a query.

------  Output ------
For each query, print a single line containing the string "YES" if the number of maximal increasing contiguous subsequences is equal to the number of maximal decreasing contiguous subsequences or "NO" otherwise (without quotes).

------  Constraints ------
$2 ≤ N ≤ 10^{5}$
$1 ≤ Q ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$ for each valid $i$
$1 ≤ L < R ≤ N$
$A_{1}, A_{2}, \ldots, A_{N}$ are pairwise distinct

------  Subtasks ------
Subtasks #1 (20 points): $Q ≤ 50$

Subtasks #2 (80 points): original constraints

----- Sample Input 1 ------ 
4 3
1 3 2 4
1 4
2 3
2 4
----- Sample Output 1 ------ 
NO
NO
YES
----- explanation 1 ------ 
For the first query, there are two maximal increasing subsequences $(1, 3)$ and $(2, 4)$, but only one maximal decreasing subsequence $(3, 2)$.