#include using namespace std; using ll = long long; using ull = unsigned long long; struct node { int start; int end; bool is; bool operator<(const node& other) const{ if(start == other.start){ return end < other.end; } return start < other.start; } bool operator==(const node& other)const { return (start == other.start) && (end == other.end); } }; void solve() { int q, n; cin >> n >> q; if(n < 1 || n > 1000000 || q < 1 || q > 100000) return; vector arr(n + 3, 0); int temp; for(int i = 1; i <= n; ++i){ cin >> temp; if(temp > 1000000 || temp < -1000000) return; arr[i] = temp; } vector> dp; dp.reserve(n + 3); for (int i = n; i > 0; --i) { dp[i] = vector(i, false); } for (int s = 1; s <= n; ++s) { dp[s][s] = true; for (int e = s + 1; e <= n; ++e) { dp[s][e] = dp[s][e-1] && (arr[e] >= arr[e-1]); } } int s,e; for (int k = 0; k < q; ++k) { cin >> s >> e; if(s < 1 || e > n) return; if (dp[s][e]) { cout << "YES\n"; } else{ cout << "NO\n"; } } } int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); return 0; }