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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n, q, l, r, t;
    cin >> n >> q;
    long long a[n];
    map<long long, vector<long long>> m;
    for (long long i = 0; i < n; i++){
        cin >> a[i];
        m[log2(a[i])].push_back(i);
    }
    for (long long i = 0; i < q; i++){
        cin >> l >> r;
        t = 1;
        for (long long j = 0; j < 30; j++){
            t = max(t, lower_bound(m[j].begin(), m[j].end(), r) - lower_bound(m[j].begin(), m[j].end(), l - 1));
        }
        cout << t << "\n";
    }
    return 0;
}