#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

int n, l, q, a, b, s, x[N], d[25][N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &x[i]);
	cin >> l;
	for (i = 1; i < n; i++) d[0][i] = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
	for (i = 1; i < 17; i++) for (j = 1; j <= n; j++) d[i][j] = d[i - 1][d[i - 1][j]];
	cin >> q;
	while (q--) {
		s = 0;
		scanf("%d %d", &a, &b);
		if (a > b) swap(a, b);
		for (i = 17; i >= 0; i--) {
			if (d[i][a] == 0) continue;
			if (d[i][a] < b) a = d[i][a], s += 1 << i;
			else if (d[i][a] == b) {i--; break;}
		}
		s += 1 << (i + 1);
		printf("%d\n", s);
	}
    return 0;
}