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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,q=1;
    cin >> n >> q;
    int a[n];
    unordered_map<int,int> p;
    int ms[n];
    int s = 0;
    for ( int i = 0 ; i < n ; i++)
    {
        cin >> a[i];
        int st = 0;
        int k = 1;
        while(k*2 <= a[i])
        {
            k*= 2;
            st++;
        }
        ms[i] = st;
        s = max(s,st);
    }
    int br = 0;
    int b[s+1][n];
    for ( int i = 0 ; i <= s ; i++)
    {
        int br = 0;
        for ( int j = 0 ; j < n ; j++)
        {
            if (ms[j] == i) br++;
            b[i][j] = br;
        }
    }
    int l,r;
    while(q--)
    {
        cin >> l >> r;
        int res = 0;
        for ( int i = 0 ; i <= s ; i++)
        {
            if ( l >= 2) res = max(res,b[i][r-1]-b[i][l-2]);
            else res = max(res,b[i][r-1]);
        }
        cout << res << endl;
    }
}