#include <bits/stdc++.h>
using namespace std;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

int p[1<<20], t[17][1<<20], n, L, q;

int main() {
	scanf("%d", &n);
	rep(i,0,n) scanf("%d", p + i);
	scanf("%d", &L);
	rep(i,0,n) t[0][i] = upper_bound(p,p+n,p[i]+L) - p - 1;
	rep(i,1,17) rep(j,0,n) t[i][j] = t[i-1][t[i-1][j]];
	scanf("%d", &q);
	rep(i,0,q) {
        int cur, fin, ret = 0;
        scanf("%d %d", &cur, &fin);
        cur--, fin--;
        if (cur > fin) swap(cur,fin);
        rep(i,17,0) {
            if (t[i][cur] < fin) {
                ret += (1<<i);
                cur = t[i][cur];
            }
        }
        printf("%d\n",ret+1);
	}
}
