#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 100005
using namespace std;
int n,q,L,a[N],f[N][20];
bool check(int x,int y,int z){
	rep (i,0,17) if (z>>i&1) x=f[x][i];
	return x>=y;
}
int main(){
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	scanf("%d",&L);
	rep (i,1,n){
		int p=upper_bound(a+i,a+1+n,a[i]+L)-a; p--;
		f[i][0]=p;
	}
	rep (j,1,17) rep (i,1,n) f[i][j]=f[f[i][j-1]][j-1];
	scanf("%d",&q);
	while (q--){
		int x,y; scanf("%d%d",&x,&y);
		if (x>y) swap(x,y);
		int l=0,r=n,mid;
		while (l<=r){
			mid=l+r>>1;
			if (check(x,y,mid)) r=mid-1; else l=mid+1;
		}
		printf("%d\n",r+1);
	}
	return 0;
}