#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1.1e5;
int N;
int X[MAXN];
int L;

int jump[MAXN][31];

int query(int a, int b) {
	int res = 0;
	for (int i = 30; i >= 0; i--) {
		if (jump[a][i] < b) {
			res += 1 << i;
			a = jump[a][i];
		}
	}
	assert(jump[a][0] >= b);
	return res + 1;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];

	cin >> L;
	for (int i = 0, j = 0; i < N; i++) {
		while (j < N && X[j] - X[i] <= L) j++;
		jump[i][0] = j-1;
	}

	for (int l = 0; l < 30; l++) {
		for (int i = 0; i < N; i++) {
			jump[i][l+1] = jump[jump[i][l]][l];
		}
	}

	int Q; cin >> Q;
	for (int q = 0; q < Q; q++) {
		int a, b; cin >> a >> b; a--, b--;
		if (a > b) swap(a, b);
		cout << query(a, b) << '\n';
	}

	return 0;
}
