#include <bits/stdc++.h>
#define fi first
#define sc second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q; cin >> n >> q;
    vi a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = 31 - __builtin_clz(a[i]);
    }


    while(q--){
        int l, r; cin >> l >> r;
        map<int,int> oc;
        int mx = 0;
        for(int i = l; i <= r; i++){
            oc[a[i]]++;
            mx = max(mx, oc[a[i]]);
        }
        cout << mx << '\n';
    }
    return 0;
}