#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


long long N, x[100000], L;
int next[100000], before[100000];
int Q;


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    cin >> L;


    // dist [l, r) <= L
    int r = 0;
    for(int l = 0; l < N; l++){
        while(r < N && x[r] - x[l] <= L){
            r++;
        }
        next[l] = r - 1;
    }

        

    
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        int cnt = 0;
        while(a < b){
            a = next[a];
            cnt++;
        }
        cout << cnt << endl;
    }
}
