#include <bits/stdc++.h>
 
using namespace std;
 
const int MAX_N = 100000;
const int MAX_LOG_N = 17;
 
int m[MAX_LOG_N][MAX_N];
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	int L, q;
	cin >> L >> q;
	for (int i = 0; i < n; i++) {
		int nex = upper_bound(x.begin() + i, x.end(), x[i] + L) - x.begin();
		nex--;
		m[0][i] = nex;
	}
 
	for (int i = 0; i + 1 < MAX_LOG_N; i++) {
		for (int j = 0; j < n; j++) {
			if (m[i][j] == n) m[i + 1][j] = n;
			else m[i + 1][j] = m[i][m[i][j]];
		}
	}
 
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a > b) swap(a, b);
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			int cur = a;
			for (int i = 0; i < MAX_LOG_N; i++) {
				if (mid & (1 << i)) cur = m[i][cur]; 
			}
			if (cur >= b) ok = mid;
			else ng = mid;
		}
		cout << ok << endl;
	}
	return 0;
}