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

const int N = 100005;

int n, L, q;
int x[N];
int rmq[N][18];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i];
	cin >> L;
	
	int pt = 1;
	for (int i = 1; i <= n; ++i) {
		while(pt <= n && x[pt] - x[i] <= L) ++pt; --pt;
		rmq[i][0] = pt;
	}

	for (int j = 1; j <= 17; ++j) {
		for (int i = 1; i <= n; ++i) rmq[i][j] = rmq[rmq[i][j-1]][j-1];
	}

	cin >> q;
	while(q--) {
		int l, r; cin >> l >> r;
		if (l > r) swap(l, r);

		int ans = 0;
		for (int j = 17; j >= 0; --j) {
			if (rmq[l][j] < r) l = rmq[l][j], ans += (1 << j);
		}
		++ans;
		printf("%d\n", ans);
	}
}