#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 1e5 + 10;
const int L = 20;
int x[N], ptr[N][L];

void precalc(int n, int len) {
    for (int j = 0; j <= L - 1; j++) {
        ptr[n + 1][j] = n + 1;
    }
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j <= L - 1; j++) {
            if (i == n) {
                ptr[i][j] = n + 1;
            }
            else if (j == 0) {
                int lef = i + 1, rig = n;
                while (lef < rig) {
                    int mid = (lef + rig) / 2;
                    if (x[mid + 1] - x[i] <= len) {
                        lef = mid + 1;
                    }
                    else {
                        rig = mid;
                    }
                }
                ptr[i][j] = lef;
            }
            else {
                ptr[i][j] = ptr[ptr[i][j - 1]][j - 1];
            }
        }
    }
}

int solve(int a, int b) {
    int ans = 0;
    for (int j = L - 1; j >= 0; j--) {
        if (ptr[a][j] <= b) {
            a = ptr[a][j];
            ans += (1 << j);
        }
    }
    if (a < b) {
        ans++;
    }
    return ans;
}

int slow(int a, int b) {
    int ans = 0;
    for (; a < b; ans++) {
        a = ptr[a][0];
    }
    return ans;
}

void stress() {
    while (1) {
        int n = rnd() % 10 + 2;
        set<int> s;
        for (int i = 1; i <= n; i++) {
            while (1) {
                int cur = rnd() % 1000 + 1;
                if (!s.count(cur)) {
                    x[i] = cur;
                    break;
                }
            }
            s.insert(x[i]);
        }
        sort(x + 1, x + n + 1);
        int mx = 0;
        for (int i = 1; i <= n - 1; i++) {
            mx = max(mx, x[i + 1] - x[i]);
        }
        int len = rnd() % 1000 + mx;
        vector<pii> queries;
        int q = 10;
        for (int i = 0; i < q; i++) {
            int a = rnd() % n + 1;
            int b = rnd() % n + 1;
            if (a > b) {
                swap(a, b);
            }
            queries.pb({a, b});
        }
        bool ok = 1;
        precalc(n, len);
        for (int i = 0; i < q; i++) {
            auto [a, b] = queries[i];
            ok &= solve(a, b) == slow(a, b);
        }
        if (ok) {
            cout << "OK" << endl;
        }
        else {
            cout << "Wrong answer" << endl;
            cout << n << endl;
            for (int i = 1; i <= n; i++) {
                cout << x[i] << " ";
            }
            cout << endl;
            cout << len << endl;
            cout << q << endl;
            for (int i = 0; i < q; i++) {
                cout << queries[i].F << " " << queries[i].S << endl;
            }
            cout << endl;
            for (int i = 0; i < q; i++) {
                auto [a, b] = queries[i];
                cout << solve(a, b) << " " << slow(a, b) << endl;
            }
            break;
        }
    }
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    int len;
    cin >> len;
    precalc(n, len);
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) {
            swap(a, b);
        }
        cout << solve(a, b) << "\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 11828