// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,lim,Q;
int x[N],L[17][N],R[17][N];

int main() {
    n=read();
    for (re int i=1;i<=n;++i) x[i]=read(); x[n+1]=2e9;
    lim=read();
    for (re int i=1,p=0;i<=n;++i) {
        while (x[i]-x[p]>lim) ++p;
        L[0][i]=p;
    }
    for (re int i=n,p=n+1;i>=1;--i) {
        while (x[p]-x[i]>lim) --p;
        R[0][i]=p;
    }
    for (re int i=1;i<=16;++i)
        for (re int j=1;j<=n;++j)
            L[i][j]=L[i-1][L[i-1][j]],R[i][j]=R[i-1][R[i-1][j]];
    for (re int i=0;i<=3;++i)
        for (re int j=1;j<=n;++j)
            printf("%d %d %d %d\n",j,1<<i,L[i][j],R[i][j]);
    Q=read();
    while (Q--) {
        int x=read(),y=read(),ans=0;
        if (x<y) {
            for (re int i=16;~i;--i)
                if (R[i][x]<=y) x=R[i][x],ans+=(1<<i);
        } else {
            for (re int i=16;~i;--i)
                if (L[i][x]>=y) x=L[i][x],ans+=(1<<i);
        }
        if (x!=y) ++ans;
        printf("%d\n",ans);
    }
    return 0;
}
