#include <iostream>
#include <algorithm>
using namespace std;
int n, q, l, r, br, rez;
int a[500005];
int main(){
    cin >> n >> q;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    while(q--){
        cin >> l >> r;
        //br = 1;
        rez = 0;
        for(int i = l; i <= r - 1; i++){
            br = 1;
            for(int j = i + 1; j <= r; j++){
                if(a[j] >= a[i] and a[i] != 1)
                    br++;
            }
            rez = max(rez, br);
        }
        cout << rez << endl;
    }
    return 0;
}