#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n,l,q,a,b,x[100000],jump[100000][17];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&x[i]);
    scanf("%d",&l);
    for(int i=n-1,j=n-1;i>=0;i--){
        while(x[j]-x[i]>l)j--;
        jump[i][0]=j;
        for(int k=1;k<=16;k++){
            jump[i][k]=jump[jump[i][k-1]][k-1];
        }
    }
    scanf("%d",&q);
    while(q--){
        scanf("%d %d",&a,&b);
        if(a>b)swap(a,b);
        a--;
        b--;
        int an=0;
        for(int i=16;i>=0&&a<b-1;){
            if(jump[a][i]>b-1){
                i--;
                continue;
            }
            an+=(1<<i);
            a=jump[a][i];
        }
        an++;
        printf("%d\n",an);
    }
    return 0;
}