#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll table[100001][17];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> v;
    ll l;  // max travel distance per day
    for(long long i=0;i<n;i++){
        long long k;
        cin>>k;
        v.pb(k);
    }
    v.pb(INT_MAX);
    cin>>l;
    int k=16;
    ll pointer=0;
    for(ll i=0;i<n;i++){
        for(ll j=pointer;j<=n;j++){
            if(v[j]-v[i]>l){
                pointer=j;
                table[i][0]=j-1;
                break;
            }
        }
    }
    for(ll j = 1; j <= k; j++) {
        for(ll i = 0; i <= n ; i++)
            table[i][j] = table[table[i][j - 1]][j-1];
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++){
        ll a,b;
        cin>>a>>b;
        if(a>b)
            swap(a,b);
        a--;
        b--;
        long long answer = 0;
        while(a<b){
            for(ll j = k; j >= 0; j--) {
                if(table[a][j] < b || j==0) {
                    answer = answer +1<<j;
                    a=table[a][j];
                    break;
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}
