#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
const int N=5e5+50,lg=32;
int n,q,a[N];
vector<int>ids[lg+1];
int main(){
    scanf("%i%i",&n,&q);
    for(int i=1;i<=n;i++)scanf("%i",&a[i]);
    for(int i=1;i<=n;i++){
        int j=0;
        while(a[i]>0)a[i]>>=1,j++;
        ids[j].pb(i);
    }
    while(q--){
        int l,r;scanf("%i%i",&l,&r);
        int res=0;
        for(int j=0;j<=lg;j++){
            int lb=lower_bound(ids[j].begin(),ids[j].end(),l)-ids[j].begin();
            int ub=upper_bound(ids[j].begin(),ids[j].end(),r)-ids[j].begin()-1;
            res=max(res,ub-lb+1);
        }
        printf("%i\n",res);
    }
    return 0;
}