#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; vector arr(n+2, 0); for(int i = 1; i <= n; i++){ cin >> arr[i]; } vector> dp(n + 2, vector(n + 2, 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(dp[s][e]){ cout << "YES\n"; }else{ cout << "NO\n"; } } } int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); return 0; }