#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7
int min(ll x, ll y){
    if(x < y)return x;
    else return y;
}
int compare_int(const void *c, const void *d){
    ll *C = (ll *)c;
    ll *D = (ll *)d;
    if(*C < *D)return 1;
    if(*C > *D)return -1;
    return 0;
}
int days(int start, int goal, int l, int n, int x[], int xx[n+1][n+1]){
    if(xx[start][goal]!=0)return xx[start][goal];
    int j = start;
    while(x[j] - x[start] <= l){
        if(j == goal)return 1;
        j++;
    }
    j--;
    xx[start][j] = 1;
    return xx[start][goal] = 1 + days(j, goal, l, n, x, xx);
}

int main(void){
    int n, l, q;
    scanf("%d", &n);
    int x[n+1];
    for(int i = 0;i < n;i++){
        scanf("%d", &x[i+1]);
    }
    scanf("%d %d", &l, &q);
    int a[q], b[q];
    for(int i = 0;i < q;i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    int xx[n+1][n+1];
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            xx[i][j] = 0;
        }
    }
    for(int i = 0;i < q;i++){
        if(a[i] > b[i]){
            int t = a[i];
            a[i] = b[i];
            b[i] = t;
        }
        printf("%d\n", days(a[i], b[i], l, n, x, xx));
    }
    return 0;
}