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

const int N = 1e5 + 5;

int n, L, q;
int a[N], nxt[18][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	cin >> L;
	int ptr = 1;
	for (int i = 1; i <= n; ++i) {
		while (ptr <= n && a[ptr] - a[i] <= L) ptr++;
		nxt[0][i] = ptr - 1;
	}
	
	for (int i = 1; i <= 17; ++i) {
		for (int j = 1; j <= n; ++j) {
			nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
		}
	}
	
	cin >> q;
	while (q--) {
		int u, v; cin >> u >> v;
		if (u > v) swap(u, v);
		int res = 1;
		for (int i = 17; i >= 0; --i) {
			if (nxt[i][u] < v) res += (1 << i), u = nxt[i][u];
		}
		cout << res << '\n';
	}
}