#include <bits/stdc++.h>

#define sz(s) s.size()
#define pb push_back
#define fr first
#define sc second
#define int long long
#define mk make_pair
#define rinat puts("rinat");

using namespace std;

const int N = 1e5 + 5;
const int inf = 1e9 + 9;

int n, ar[N], a, b, q, dp[N], l, pos[N], cnt;

main()
{
    cin >> n;
    for( int i = 1; i <= n; i++ )
        cin >> ar[i];
    for( int i = 1; i <= n; i++ )
        dp[i] = inf;
    cin >> l;
    for( int i = 1; i <= n; i++ )
    {
        dp[i] = upper_bound(ar + 1, ar + 1 + n, ar[i] + l) - ar - 1;
    }
    cin >> q;
    while( q-- )
    {
        cin >> a >> b;
        if( b < a )
            swap(a, b);
        while( dp[a] <= b )
        {
            cnt++;
            dp[a] = dp[dp[a]];
        }
        cout << cnt << endl;
        cnt = 0;
    }
}





