#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
//samo za x>=1
int ceolog2(long long x){
    if(x==1)return 0;
    else{
        int k=-1;
        while(x>0){
            x/=2;
            k++;
        }
        return k;
    }
}
void solve(){
    int n, q;cin>>n>>q;
    vector<long long>pr(n);
    vector<int>v(n, -1);
    for(int i=0;i<n;i++){
        cin>>pr[i];
    }
    //MOLIM TE RADI AMAN VISE
    int l ,r, o;
    for(int i=0;i<q;i++){
        cin>>l>>r;
        map<int, int>f;
        for(int i=l-1;i<r;i++){
            if(v[i]==-1){v[i]=ceolog2(pr[i]);}
            f[v[i]]++;
        }
        o=1;
        for(auto x : f){
            o=max(x.second, o);
        }
        cout<<o<<endl;
    }
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;t=1;//cin>>t;
    while(t--)solve();
    return 0;
}