#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define pre(i,l,r) for(int i=(l);i>=(r);--i)
const int N=2e5+5;
int n,a[N],st[N][20];
inline int ask(int x,int y){
int k=log2(y-x+1);
return max(st[x][k],st[y-(1<<k)+1][k]);
}
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n;
rep(i,1,n) cin>>a[i];
rep(i,1,n) st[i][0]=lower_bound(a+1,a+n+1,a[i]*2)-a-i;
rep(j,1,19){
rep(i,1,n-(1<<j)+1){
st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
}
}
int q;
cin>>q;
while(q--){
int x,y;
cin>>x>>y;
int l=0,r=(y-x+1)/2,ans=0;
while(l<=r){
int mid=(l+r)>>1;
if(ask(x,x+mid-1)<=y-x+1-mid){
l=mid+1;ans=mid;
}else{
r=mid-1;
}
}
cout<<ans<<'\n';
}
return 0;
}