#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
int n,z;
ll t[111111];
ll nex[50][111111];
int q;

ll che(int x){

	ll l=x+1,r=n,mid=(r+l)/2;
	
	while(r-l>1){
		ll ab=t[mid]-t[x];
		if(ab>z)r=mid;
		else l=mid;
		mid=(r+l)/2;
	}

	return l;
}

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	cin>>z;

	rep(i,n){
		nex[0][i]=che(i);
	}

	rep(i,40){
		rep(j,n){
			if(nex[i][j]==n)nex[i+1][j]=n;
			else nex[i+1][j]=nex[i][nex[i][j]];
		}
	}


	cin>>q;
	rep(i,q){
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		a--;b--;
		ll l=0,r=n,mid=(r+l)/2;
		ll tmp=a;
		
		while(r-l>1){
			tmp=a;
			ll one=1;
			rep(j,40){
				if((one<<j)&mid)tmp=nex[j][tmp];
			}

			if(tmp>=b)r=mid;
			else l=mid;
			mid=(r+l)/2;
		}
		cout<<r<<endl;
	}
	return 0;
}
