#include <bits/stdc++.h>

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n, x[N], suf[N];

int nxt[N][22], log2n;

inline int Calc(int a, int b) {
	int res = 0;
	Fordown (i, log2n, 0)
		if (nxt[a][i] < b) a = nxt[a][i], res |= 1 << i;
	return res + 1;
}

int main() {

	File();

	n = read();
	For (i, 1, n)
		x[i] = read();

	int L = read();

	suf[1] = 1;
	for (int i = 1; i <= n; ++ i, suf[i] = suf[i - 1])
		while (abs(x[suf[i] + 1] - x[i]) <= L) ++ suf[i];

	For (i, 1, n)
		nxt[i][0] = suf[i];

	log2n = ceil(log2(n));
	For (j, 1, log2n) For (i, 1, n)
		nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];

	int q = read();
	For (i, 1, q) {
		int a = read(), b = read();
		if (a > b) swap(a, b);
		printf ("%d\n", Calc(a, b));
	}

    return 0;

}
