You've got an array, consisting of *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. Also, you've got *m* queries, the *i*-th query is described by two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>. Numbers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> define a subsegment of the original array, that is, the sequence of numbers *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub></sub>, *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub> + 1</sub>, *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub> + 2</sub>, ..., *a*<sub class="lower-index">*r*<sub class="lower-index">*i*</sub></sub>. For each query you should check whether the corresponding segment is a ladder. 

A ladder is a sequence of integers *b*<sub class="lower-index">1</sub>, *b*<sub class="lower-index">2</sub>, ..., *b*<sub class="lower-index">*k*</sub>, such that it first doesn't decrease, then doesn't increase. In other words, there is such integer *x* (1 ≤ *x* ≤ *k*), that the following inequation fulfills: *b*<sub class="lower-index">1</sub> ≤ *b*<sub class="lower-index">2</sub> ≤ ... ≤ *b*<sub class="lower-index">*x*</sub> ≥ *b*<sub class="lower-index">*x* + 1</sub> ≥ *b*<sub class="lower-index">*x* + 2</sub>... ≥ *b*<sub class="lower-index">*k*</sub>. Note that the non-decreasing and the non-increasing sequences are also considered ladders.
The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of array elements and the number of queries. The second line contains the sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), where number *a*<sub class="lower-index">*i*</sub> stands for the *i*-th array element.

The following *m* lines contain the description of the queries. The *i*-th line contains the description of the *i*-th query, consisting of two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ *n*) — the boundaries of the subsegment of the initial array.

The numbers in the lines are separated by single spaces.
def ss(a,n):
    minima = [] 
    for i in range(n):
        if i==0:
            if a[i]<a[i+1]:
                minima.append(1)
            else:
                minima.append(0)
        elif i==n-1:
            if a[i]<a[i-1]:
                minima.append(minima[-1]+1)
            else:
                minma.append(minima[-1])
        else:
            if a[i]<a[i-1] and a[i]<a[i+1]:
                minima.append(minima[-1]+1)
            else:
                minima.append(minima[-1])
    return minima                              

def ss2(a,l,r):
    l = l-1
    r = r-1
    if l==0:
        if a[l]==0:
            if a[r]==0 or a[r]==1:
                return 'YES'
            else:
                return 'NO'
        else:
            if a[r]==1:
                return 'YES'
            elif a[r]==2 and a[r-1]==1:
                return 'YES'
            else:
                return 'NO'
    if a[r]-a[l]==0:
        return "YES"
    elif a[r]-a[l]==1 and a[r-1]!=a[r]:
        return 'YES'
    else:
        return "NO"
    
    
n,q = map(int,input().split())
a = list(map(int,input().split()))

minima = ss(a,n)
for _ in range(q):
    l,r = map(int,input().split())
    print(ss2(minima,l,r))