#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    int q;
    cin >> n >> q;
    vector<int> A(n);
    vector<int> stepdv(n);
    long long najvstep = 0;
    for (int i=0;i<n;i++) {
            cin >> A[i];
            int stp = 0;
            while (1 << stp <= A[i]) stp++;
            stepdv[i] = stp;
            if (stepdv[i]>najvstep) najvstep = stepdv[i];
    }
    for (int i=0;i<q;i++) {
        int l;
        int r;
        cin >> l >> r;
        l--;
        vector<int> stepeni(najvstep+1);
        long long maxi = 0;
        for (int j=l;j<r;j++) {
            stepeni[stepdv[j]]++;
            if (stepeni[stepdv[j]]>maxi) maxi = stepeni[stepdv[j]];
        }
        cout << maxi << '\n';
    }
    return 0;
}