#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, L, Q;
    cin >> N;
    vector<int> X(N + 3);
    rep(i, N) cin >> X[i + 1];
    X[0] = INT32_MIN;
    //X[N + 1] = INT32_MAX;
    X[N + 1] = X[N] + 1;
    X[N + 2] = INT32_MAX;
    cin >> L >> Q;
    vector<pair<int, int>> ab(Q);
    rep(i, Q) {
        cin >> ab[i].first >> ab[i].second;
        if (ab[i].first > ab[i].second) swap(ab[i].first, ab[i].second);
    }

    vv<int> rightLimit_dbl = vvec(18, N + 3, -1);

    rep(i, 1, N + 2) {
        rightLimit_dbl[0][i] = (upper_bound(all(X), X[i] + L) - X.begin()) - 1;
    }

    rep(b, 1, 18) {
        rep(i, 1, N + 2) {
            rightLimit_dbl[b][i] = rightLimit_dbl[b - 1][rightLimit_dbl[b - 1][i]];
        }
    }

    rep(i, Q) {
        int a = ab[i].first;
        int ans = 0;
        while (a != ab[i].second) {
            for (int k = 17; k >= 0; --k) {
                if (rightLimit_dbl[k][a] <= ab[i].second) {
                    ans += 1 << k;
                    a = rightLimit_dbl[k][a];
                    break;
                }
            }
        }

        write(ans);
    }
}