#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;++i)
int r[18][100000],x[100000];
int main(){
int i,j,n,L,Q,a,b;
cin>>n;
rep(i,n)cin>>x[i];
cin>>L;
rep(i,n)r[0][i]=upper_bound(x,x+n,x[i]+L)-x-1;
rep(i,17)rep(j,n)r[i+1][j]=r[i][r[i][j]];
cin>>Q;
rep(j,Q){
cin>>a>>b;--a;--b;
if(a>b)swap(a,b);
int ans=0,now=a;
for(i=17;i>=0;--i)if(r[i][now]<b){now=r[i][now];ans+=1<<i;}
if(now<b){now=r[0][now];++ans;}
cout<<ans<<'\n';
}
}
