#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int LL;
const LL MAX=1e9+7;
vector<LL> x;
int go[35][100005];
LL s[100005];
int main(){
	LL n,l,q;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		x.push_back(a);
	}
	cin>>l>>q;
	for(j=0;j<n;j++){
		auto itr=upper_bound(x.begin(),x.end(),x[j]+l);
		go[0][j]=(int)distance(x.begin(),itr-1);
	}
	for(i=1;i<=30;i++){
		for(j=0;j<n;j++){
			go[i][j]=go[i-1][go[i-1][j]];
		}
	}
	for(i=0;i<q;i++){
		cin>>a>>b;
		a--,b--;
		if(a>b)swap(a,b);
		for(j=30;j>=0;j--){
			if(go[j][a]>=b)continue;
			s[i]+=(1<<j);
			a=go[j][a];
		}
		s[i]++;
	}
	for(i=0;i<q;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}
		
		
