rt,
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
namespace IO {
#define ll long long
inline ll rad() {
char c=getchar();
int f=1;
ll x=0;
while(c<'0' || c>'9') {
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0' && c<='9') {
x=(x<<1)+(x<<3)+c-'0';
c=getchar();
}
return x*f;
}
void write(ll x) {
if(x<0) {
x=-x;
putchar('-');
}
if(x>9)
write(x/10);
putchar(x%10+'0');
}
}
using namespace IO;
#define N 100005
int n, m;
int a[N];
int cnt[N];
int pos[N];
bool ans[N];
bool res;
struct Q {
int l, r;
int k;
}q[N];
void add(int n) {
cnt[a[n]]++;
if(cnt[a[n]]>1)
res=0;
else
res=1;
}
void sub(int n) {
cnt[a[n]]--;
if(cnt[a[n]]>1)
res=0;
else
res=1;
}
int main() {
n=rad(), m=rad();
int t=sqrt(n);
for(int i=1; i<=n; i++) {
a[i]=rad();
pos[i]=i/t;
}
for(int i=1; i<=m; i++) {
q[i]={(int)rad(), (int)rad(), i};
}
std::sort(q, q+m, [](Q x, Q y) {
return pos[x.l]==pos[y.l]? x.r<y.r:pos[x.l]<pos[y.l];
});
int l=1, r=0;
for(int i=1; i<=m; i++) {
while(q[i].l<l) add(--l);
while(q[i].r>r) add(++r);
while(q[i].l>l) sub(l++);
while(q[i].r<r) sub(r--);
ans[q[i].k]=res;
}
for(int i=1; i<=m; i++) {
puts(!ans[i]? "YES":"NO");
}
return 0;
}