#include <iostream>
#include <vector>
#include <bits/ios_base.h>
using namespace std;

int main()
{
    cin.tie(NULL);
    int n;
    int q;
    cin >> n >> q;
    vector<int> A(n);
    vector<int> stepdv(n);
    vector<int> celi{1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912};
    long long najvstep = 0;
    for (int i=0;i<n;i++) {
            cin >> A[i];
            int stp = 1;
            for (int j=0;j<30;j++) {
                if (celi[j]>A[i]) {
                    stepdv[i] = j;
                    break;
                }
            }
            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;
}