#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;cin>>N;
    int x[N];
    REP(i,N)cin>>x[i];
    LL L;cin>>L;
    int logN = (int)log2(N) + 1;

    int doub[N][logN+1];
    fill(doub[0],doub[N],x[N-1]+1);
    REP(i,N-1)doub[i][0]=upper_bound(x,x+N,x[i]+L)-x-1;
    REP(k,logN)REP(i,N)doub[i][k+1]=doub[min(N-1,doub[i][k])][k];

    int q;cin>>q;
    REP(i,q){
        int a,b;cin>>a>>b;
        if(a>b)swap(a,b);
        a--;b--;

        int ans=0;
        for(int i=logN-1;i>=0;i--){
            if(doub[a][i]<b){
                ans+= 1<<i;
                a = doub[a][i];
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}