#include <iostream>
#include <utility>
#include <algorithm>
#define inf 1000000007

using namespace std;

int N, L, Q;
int x[100005];
int next[17][100005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> x[i];
	x[N] = x[N-1]+1;
	cin >> L;
	
	int p;
	for(int i = 0; i <= N; i++){
		next[0][i] = upper_bound(x, x+N+1, x[i] + L) - x - 1;
	}
	for(int i = 1; i < 17; i++){
		for(int j = 0; j <= N; j++){
			next[i][j] = next[i-1][next[i-1][j]];
		}
	}
	
	cin >> Q;
	int a, b;
	for(int q = 0; q < Q; q++){
		cin >> a >> b;
		a--, b--;
		if(a > b){
			int t = a;
			a = b, b = t;
		}
		
		int cur = a, ans = 0;
		for(int i = 16; i >= 0; i--){
			if(x[next[i][cur]] <= x[b]){
				cur = next[i][cur];
				ans += 1<<i;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}