/*
 * Improve search to use upper_bound()
 * Computational Complexity O(NQ)  --- maybe not change from e1.cpp
 */
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

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) {
        int x;
        cin >> x;
        vec.push_back(make_pair(x, i+1));
    }
    cin >> L;
    cin >> Q;

    sort(vec.begin(), vec.end());

    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) {
            auto it = upper_bound(vec.begin(), vec.end(), make_pair(vec[ai].first+L, 100006));
            ai = it - vec.begin() - 1;
            day++;
        }
        cout << day << endl;
    }




    return 0;
}
