#include <bits/stdc++.h>

int n, L, Q, lg;
std::vector <int> a;
std::vector <std::pair<int,int>> query;
std::vector <std::vector<int>> reach;

int main () {
	std::cin >> n;
	a.resize (n+1);
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i];
	std::cin >> L >> Q;
	query.resize (Q);
	for (int i = 0; i < Q; ++i)
		std::cin >> query[i].first >> query[i].second;
	lg = std::__lg (n);
	if ((1<<lg) < n) ++lg;
	std::cerr << "lg = " << lg << "\n";
	reach.assign (n+1, std::vector<int> (lg+1, 0));
	for (int i = 1; i <= n; ++i) {
		int l = i, r = n, mid;
		while (l <= r) {
			mid = l + r >> 1;
			if (a[mid]-a[i] <= L)
				reach[i][0] = std::max(mid,reach[i][0]), l = mid+1;
			else
				r = mid-1;
		}
	}

	for (int j = 1; j <= lg; ++j)
		for (int i = 1; i <= n; ++i)
			reach[i][j] = reach[reach[i][j-1]][j-1];

	for (int i = 0; i < Q; ++i) {
		int go, st = query[i].first, ed = query[i].second;
		if (st > ed) std::swap (st, ed);
		for (go = 0; go <= lg; ++go)
			if (reach[st][go] >= ed) break;
		int ans = 0;
		for (; go >= 0 and st < ed; --go)
			if (reach[st][go] <= ed)
				st = reach[st][go], ans += (1<<go);
		if (st < ed) ans++;
		std::cout << ans << "\n";
	}
	return 0;
}