#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;
int dp[maxn][20];
int x[maxn];

int main(){
    int N, L, Q, a, b;
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        scanf("%d", &x[i]);
    }
    scanf("%d", &L);
    x[0] = x[1];
    for(int i = 1, l = 0; i <= N; i++){
        while(x[i] - x[l] > L) l++;
        dp[i][0] = l;
        for(int j = 1; j < 20; j++){
            dp[i][j] = dp[dp[i][j - 1]][j - 1];
        }
    }
    scanf("%d", &Q);
    while(Q--){
        scanf("%d%d", &a, &b);
        if(a < b) swap(a, b);
        int ans = 0;
        for(int d = 19; d >= 0; d--){
            if(dp[a][d] >= b){
                ans += (1 << d);
                a = dp[a][d];
            }
        }
        if(a != b) ans++;
        printf("%d\n", ans);
    }
    return 0;
}
