#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N,Q;
	cin>>N>>Q;
	vector<int> a(N);
	vector<vector<int>> d(31);
	for (int i=0;i<N;i++){
		
		cin>>a[i];
		int p = 1;
		for (int j=0;j<30;j++){
			if ((a[i]>=p) and (a[i] < p*2)){
				d[j].push_back(i);
				break;
			}
			p=p*2;
		}	
	}
	
/*	for (int i=0;i<30;i++){
		cout<<pow(2,i)<<" - "<<pow(2,i+1)-1<<": ";
		for (int j = 0;j < d[i].size();j++){
			cout<<d[i][j]<<' ';
		}
		cout<<'\n';
	}
	
	cout<<"UPITI\n";  
	*/
	while(Q--){
		
		int L,R;
		cin>>L>>R;
		L--; R--;
		int rez=-1;
		for (int i = 0;i<30;i++){
			if(d[i].size()==0) continue;
			int l = distance(d[i].begin(),lower_bound(d[i].begin(),d[i].end(),L));
			int r = distance(d[i].begin(),upper_bound(d[i].begin(),d[i].end(),R)) - 1;
	//		cout<<l<<" "<<r<<"   "<<r-l+1<<'\n';
			if (r-l+1>rez){
				rez = r-l+1;
			}
		}
		cout<<max(rez,1)<<'\n';
	}
	
	
	return 0;
}