#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
ll a[100000];
ll dp[18][100000];
int main() {
	int n;cin >> n;
	rep(i, n)cin >> a[i];
	ll l;cin >> l;
	rep(i, n) {
		int k = upper_bound(a, a + n, a[i] + l) - a;k--;
		dp[0][i] = k;
	}
	Rep(i, 1, 18) {
		rep(j, n) {
			dp[i][j] = dp[i - 1][dp[i - 1][j]];
		}
	}
	int q;cin >> q;
	rep(aaa, q) {
		int s, t;cin >> s >> t;s--;t--;
		if (s > t)swap(s, t);
		int out = 0;
		while (s < t) {
			rep(j, 18) {
				if (dp[j][s] >= t) {
					if (j > 0) {
						out += 1 << (j - 1);
						s = dp[j - 1][s];
					}
					else {
						out++;
						s = t;
					}
					break;
				}
			}
		}
		cout << out << endl;
	}
	return 0;
}