#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    vector<int> x(n);
    map<int, int> mp = {};
    FOR(i, 0, n) {
        cin >> x[i];
        mp[x[i]] = i;
    }
    int l;
    cin >> l;
    vector<vector<int> > st(n, vector<int>(21));
    FOR(i, 0, n)
        st[i][0] = mp[*(--upper_bound(x.begin(), x.end(), x[i] + l))];
    FOR(j, 1, 21) {
        FOR(i, 0, n) {
            st[i][j] = st[st[i][j - 1]][j - 1];
            // cout << i << ' ' << j << ' ' << st[i][j] << endl;
        }
    }
    int m, a, b, cr, ans;
    cin >> m;
    while (m--) {
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        --a; --b;
        ans = 0;
        cr = a;
        ROF(j, 20, -1) {
            if (st[cr][j] < b) {
                cr = st[cr][j];
                ans += (1 << j);
            }
        }
        ++ans;
        cout << ans << "\n";
    }

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define LOG_MAX 30
// 1つ先が無い(木の根など)場合、値を負かn以上とする
template <typename T>
class Doubling {
    const size_t n;
    vector<vector<T>> next;
public:
    Doubling() {}
    Doubling(vector<T> first_row) 
    : n(first_row.size()), 
      next(LOG_MAX, vector<T>(n)) {
        copy(first_row.begin(), first_row.end(), next[0].begin());
        for (size_t i=1; i<LOG_MAX; i++) {
            for (size_t j=0; j<n; j++) {
                next[i][j] = (
                    (0 <= next[i-1][j] && (size_t)next[i-1][j] < n)
                    ? next[i-1][(size_t)next[i-1][j]]
                    : next[i-1][j]
                );
            }
        }
    }

    T query(T i, int step=1) {
        for (int k=LOG_MAX-1; k>=0; k--) {
            if ((step >> k) & 1) i = next[(size_t)k][(size_t)i];
            if (i < 0 || n <= (size_t)i) break;
        }
        return i;
    }
};

int main() {
    int n, q;
    cin >> n;
    long x[n], l;
    for (auto &xi:x) cin >> xi;
    cin >> l >> q;
    vector<int> first_row(n);
    for (int i=0; i<n; i++) {
        int ub = upper_bound(x+i, x+n, x[i] + l) - x;
        first_row[i] = ub - 1;
    }
    Doubling<int> db(first_row);
    for (int i=0, a, b; i<q; i++) {
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        int l=0, r=n-1;
        while (r - l > 1) {
            int m = (l + r + 1) / 2,
                dest = db.query(a, m);
            if (b > dest) l = m;
            else r = m; 
        }
        cout << r << '\n';
    }
    return 0;
}
