#include<bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, L;
int a[N], pre[N][35];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);

    cin >> L;
    memset(pre, -1, sizeof pre);
    for(int i = 1; i <= n; ++i) {
        int l = i, r = n;
        while(r > l)    {
            int m = (l + r + 2) / 2;
            if(a[m] - L > a[i]) r = m - 1;
            else l = m;
        }
        pre[i][0] = l;
    }
    for(int i = 1; i <= 30; ++i)
        for(int j = 1; j <= n; ++j) if(pre[j][i - 1] != -1) {
            pre[j][i] = pre[pre[j][i - 1]][i - 1];
        }
    int q; cin >> q;
    while(q --) {
        int ha, hb; cin >> ha >> hb;
        if(a[ha] > a[hb]) swap(ha, hb);

        int res = 0;
        for(int i = 20; i >= 0; --i)    if(a[pre[ha][i]] <= a[hb])  {
            ha = pre[ha][i]; res += (1 << i);
            if(ha == hb) break;
        }
        cout << res << '\n';
    }
}
