#include <bits/stdc++.h>
using namespace std;

vector<long long> a;

int main()
{
    int n, q; cin >> n >> q;
    for(int i = 0; i < n; i++){
        long long x; cin >> x;
        a.push_back(x);
    }
    long long stI = 1;
    int brojac = 0;
    while(q--){
        map<int, int> mapa;
        int l, r;
        cin >> l >> r;
        int rez = -10;
        for(int i = l-1; i <= r-1; i++){
            mapa[floor(log2(a[i]))]++;
        }
        for(auto a : mapa){
            rez = max(rez, a.second);
        }
        cout<<rez<<endl;
    }
    return 0;
}