#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;

int n,max_dist;
int arr[N],MAX[N];
int dp[N][30];

int bin_search(int l,int val) {
	for(int i=30;i>=0;i--) {
		int r = l + (1<<i);
		if(r>n) continue;
		else {
			if(arr[r] - val <= max_dist) l += (1<<i);
		}
	}
	return l;
}

int find1(int a,int b) {
	if(a>b) swap(a,b);
	if(arr[b] - arr[a]<=max_dist) return 1;
	int ans = 0;
	for(int i=30;i>=0;i--) {
		if((a + (1<<i)) < b && dp[a][i]!=-1) {
			ans += (1<<i);
			a = dp[a][i];
		}
	}
	return ans;
}

main() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	cin>>max_dist;
	for(int i=1;i<=n;i++) {
		int id = bin_search(i,arr[i]);
		MAX[i] = id;
	}
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=30;j++) {
			dp[i][j] = -1;
		}
	}
	for(int i=1;i<=n-1;i++) dp[i][0] = MAX[i];
	for(int j=1;j<=30;j++) {
		for(int i=1;i<=n;i++) {
			if(dp[i][j-1] != -1) {
				dp[i][j] = dp[dp[i][j-1]][j-1];
			}
		}
	}
	int q;	cin>>q;
	while(q--) {
		int a,b;	cin>>a>>b;
		cout<<find1(a,b)<<endl;
	}
	/*for(int i=1;i<=n-1;i++) {
		cout<<i<<":";
		for(int j=0;j<=5;j++) {
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
}