#pragma GCC Optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define lp(i,begin,end) for (int i=begin;i<end;i++)
const int N=1e5+5,M=N*N,OO=0x3f3f3f3f;
int n,l,q,arr[N],x,y;
int lst,far,d;
struct query{
    int x,y,qnum,ans;
}qarr[N];
bool cmp(query a,query b){
    if(a.x==b.x)return a.y<b.y;
    return a.x<b.x;
}
int mnroot(int t){
    int cur=far,dis=d,idx;
    while(cur<t){
        idx=lower_bound(arr,arr+n,arr[cur]+l);
        if(idx==n){far=n-1; d=dis+1;    return d;}
        if(arr[idx]>arr[cur]+l)idx--;
        if(arr[idx]>=t){far=idx; d=dis+1;    return d;}
        cur=idx;    dis++;
    }
    return d;
}
bool cmp2(query a,query b){
    return a.qnum<b.qnum;
}
int main(){
    scanf("%d",&n);
    lp(i,0,n)scanf("%d",arr+i);
    scanf("%d%d",&l,&q);
    lp(i,0,q){
        scanf("%d%d",&x,&y);
        x--,y--;
        qarr[i].x=min(x,y),qarr[i].y=max(x,y),qarr[i].qnum=i;
    }
    sort(qarr,qarr+q,cmp);
    lst=qarr[0].x,far=qarr[0].x;
    lp(i,0,q){
        if(qarr[i].x!=lst){lst=far=qarr[i].x;    d=0;}
        qarr[i].ans=mnroot(qarr[i].y);
    }
    sort(qarr,qarr+q,cmp2);
    lp(i,0,q){
        printf("%d\n",qarr[i].ans);
    }
}
