#include <iostream>
#include <vector>
using namespace std;
int najvecapoz(int a,int x)
{
    if (a == 0) return x;
    else return najvecapoz(a / 2, x + 1);
}
int najvecavrednost(vector<int> a,int n)
{
    int max = 0;
    for (int i = 0; i < n; i++)
        if (max < a[i]) max = a[i];
    return max;
}
int main()
{
    int n, q,t,l,d;
    cin >> n;
    cin >> q;
    vector<int> a;
    vector<int> stepeni;
    vector<int> resenja;
    for (size_t i = 0; i < 40; i++)
        stepeni.push_back(0);
    for (size_t i = 0; i < n; i++)
    {
        cin >> t;
        a.push_back(najvecapoz(t,-1));
    }
    for (size_t i = 0; i < q; i++)
    {
        cin >> t;
        l = t - 1;
        cin >> t;
        d = t - 1;
        for (size_t j = l; j <= d; j++)
            stepeni[a[j]]++;
        resenja.push_back(najvecavrednost(stepeni, 40));
        for (size_t g= 0; g < 40; g++)
        {
            stepeni[g] = 0;
        }
    }
    for (size_t i = 0; i < q; i++)
        cout << resenja[i] << '\n';

    
}