#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int r[40][100010];
signed main(int argc, char const *argv[]) {
    int N,L,Q;
    cin>>N;
    vector<int> x(N);
    REP(i,N) cin>>x[i];
    cin>>L>>Q;

    REP(i,N) {
        r[0][i]=distance(begin(x),upper_bound(ALL(x),x[i]+L))-1;
    }
    REP(j,31) {
        REP(i,N) {
            r[j+1][i]=r[j][r[j][i]];
        }
    }

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

        int ans=0;
        int t=a;
        REP(i,31) {
            t=r[0][t];
            ans++;
            if(t>=b) break;
        }
        cout<<ans<<endl;
    }
    return 0;
}
