#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;++i)
#define c(a) cin>>a;
int r[18][100000],x[100000],i,j,n,L,a,b,A,N;
int main(){
c(n)
rep(i,n)c(x[i])
c(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]];
c(L)
rep(j,L){
c(a)c(b)--a;--b;
if(a>b)swap(a,b);
A=0;N=a;
for(i=17;i>=0;--i)if(r[i][N]<b){N=r[i][N];A+=1<<i;}
if(N<b)++A;
cout<<A<<endl;
}
}
