#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
int n, x[N], jump[N][20], l, q;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> x[i];
    cin >> l;

    for (int i = 1; i <= n; ++i) {
        int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
        jump[i][0] = pos - 1;
    }
    for (int j = 1; j < 20; ++j) {
        for (int i = 1; i <= n; ++i) {
            jump[i][j] = jump[ jump[i][j - 1] ][j - 1];
        }
    }
    cin >> q;
    while(q--) {
        int ans = 0, a, b; cin >> a >> b;
        if(a > b) swap(a, b);
        for (int i = 19; i >= 0; --i) if(jump[a][i] < b) ans += (1 << i), a = jump[a][i];
        cout << ans + 1 << '\n';
    }

    return 0;
}
