/*
 *
 */
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int x[100005];
//int a[100005];
//int b[100005];
vector<pair<int, int>> vec; //  x_i, city

int main(){
    //freopen("e.in", "r", stdin);
    int n;
    int L;
    int Q;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        vec.push_back(make_pair(x[i], i+1));
    }
    cin >> L;
    cin >> Q;

    sort(vec.begin(), vec.end());
    sort(x, x+n);

    for (int j = 0; j < Q; ++j) {
        int a, b;
        int ai, bi;
        cin >> a >> b;
        for (int i = 0; i < n; ++i) {
            if (vec[i].second == a) ai = i;
            if (vec[i].second == b) bi = i;
        }

        if (ai > bi) { swap(ai, bi); }

        ll day = 0;
        while (ai < bi) {
            int new_ai = ai;
            while(vec[new_ai].first <= vec[ai].first + L) {
                new_ai = new_ai+1;
            }
            ai = new_ai - 1;
            day++;
        }
        cout << day << endl;
    }




    return 0;
}
