#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n, q, a[100010], b[100010];
ll x[100010], l;
int st[20][100010],rst[20][100010];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);



    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    cin >> l >> q;
    for(int i = 0; i < q; i++) {
            cin>> a[i] >> b[i];
            a[i] --;
            b[i] --;
    }

    for(int i = 0; i < 20; i++){
        for(int j = 0; j < 100010;j++){
            st[i][j] = n-1;
            rst[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        st[0][i] = (upper_bound(x,x+n,x[i]+l)-x) -1;
        rst[0][i] = (lower_bound(x,x+n,x[i]-l)-x);
    }
    //cout<<endl;
    int tem = 2;
    for(int i = 1; i < 20; i++){
        for(int j = 0; j < n; j++){
            st[i][j] = st[i-1][st[i-1][j]];
            rst[i][j] = rst[i-1][rst[i-1][j]];
        }

        tem *= 2;
        if(tem >= n)break;
    }

    for(int i = 0; i < q; i++){
        int aa = a[i], bb = b[i];
        int ans = 0;
        if(aa < bb){
            for(int i = 19; i>=0; i--){
                if(st[i][aa] < bb){
                    aa = st[i][aa];
                    ans += pow(2,i);
                }
            }
        }
        else{
            for(int i = 19; i>=0; i--){
                if(rst[i][aa] > bb){
                    aa = rst[i][aa];
                    ans += pow(2,i);
                    //cout<<endl<<aa<<'#';
                }
            }
        }
        ans+=1;
        cout<<ans<<endl;
    }

    return 0;
}
