#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 1e5 + 5;

int n, ar[N], tin[N], tout[N], L, timer, lg, m, h[N];

vector <vector <int> > g, up;

void dfs (int v, int p = n)
{
    tin[v] = ++timer;

    up[v][0] = p;

    for (int i = 1; i <= lg; i++)
        up[v][i] = up[ up[v][i - 1] ][i - 1];

    for (auto to : g[v])
        if (to != p)
            h[to] = h[v] + 1,
            dfs(to, v);

    tout[v] = ++timer;
}
bool upper (int a, int b)
{
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}
int lca (int a, int b)
{
    if (upper(a, b)) return a;
    if (upper(b, a)) return b;
    for (int i = lg; i >= 0; i--)
        if ( !upper( up[a][i], b ) )
            a = up[a][i];

    return up[a][0];
}
main ()
{
    cin >> n;

    m = n;
    while (m)
        m >>= 1,
        lg++;


    g.resize(n + 1);
    up.resize(n + 1);

    up[0].resize(lg + 1);

    for (int i = 1; i <= n; i++)
        scanf("%d", &ar[i]),
        up[i].resize(lg + 1);

    cin >> L;

    for (int i = 1; i <= n; i++)
    {
        int pos = upper_bound( ar + i, ar + n + 1, ar[i] + L ) - ar - 1;
        g[i].pb( pos );
        g[pos].pb( i );
//        cout << i << " " << pos << endl;
    }
    dfs(n);
    cin >> m;
    while (m--)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x > y)
            swap(x, y);

        printf("%d\n", h[x] - h[lca(x, y)] );
    }
}
