#include <bits/stdc++.h>
using namespace std;
using Pint = pair<int, int>;

int N, L, Q;
vector<int> x;
vector<Pint> q;

int main()
{
    cin >> N;
    x.resize(N);
    for (auto &val : x) cin >> val;
    x.push_back(x[N-1]+1);
    cin >> L >> Q;
    q.resize(Q);
    for (int i=0; i<Q; i++)
    {
        int t1, t2;
        cin >> t1 >> t2;
        
        if (t1>t2) swap(t1, t2);
        q[i] = Pint(t1-1, t2-1);
    }
    int lgN = 1;
    {
        int tmp = N;
        while (tmp)
        {
            lgN++;
            tmp /= 2;
        }
    }
    vector<vector<int> > next(lgN+1, vector<int>(N+1));
    for (int i=0; i<=N; i++)
    {
        next[1][i] = min(distance(x.begin(), lower_bound(x.begin(), x.end(), x[i]+L+1)) - 1, N);
    }

    for (int n=2; n<=lgN; n++)
    {
        for (int i=0; i<=N; i++)
        {
            next[n][i] = next[n-1][next[n-1][i]];
        }
    }
    // for (auto vec : next)
    // {
    //     for (auto val : vec) cout << val << " ";
    //     cout << endl;
    // }

    for (auto query : q)
    {
        int ans = 0;
        int now = query.first;
        for (int n = lgN; n>0; n--)
        {
            if (next[n][now] < query.second)
            {
                ans += n;
                now = next[n][now];
            }
        }
        cout << ans + 1 << endl;
    }
}
