#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int a[100010], b[100010], x[100010], r[100010][20];

int intcmp(const void *a, const void *b) {
	int c = *(int *)a-*(int *)b;
	if (c>0) return 1;
	else if (!c) return 0;
	else return -1;
}

int main() {
	int D, from, i, j, k, key, L, N, *ptr, Q, to;
	scanf("%d", &N);
	for (i=0;i<N;i++) scanf("%d", &x[i]);
	scanf("%d%d", &L, &Q);
	for (i=0;i<Q;i++) scanf("%d%d", &a[i], &b[i]);

	for (i=0;i<N-1;i++) {
		j = 0;
		key = x[i]+L;
		ptr = bsearch(&key, x, N, sizeof(int), intcmp);
		while (ptr == NULL) { --key; ptr = bsearch(&key, x, N, sizeof(int), intcmp); }
		r[i][0] = (ptr-x)+1;
	}
	r[N-1][0] = N;
	for (k=1;k<20;k++) {
		for (i=0;i<N-1;i++) {
			r[i][k] = r[r[i][k-1]-1][k-1];
		}
		r[N-1][k] = N;
	}

	for (i=0;i<Q;i++) {
		D = 0;
		if (a[i]>b[i]) {
			from = b[i]; to = a[i];
			while ((ptr = bsearch(&to, r[from-1], 20, sizeof(int), intcmp)) == NULL) { --to; }
			k = (ptr-r[from-1])+1;
			j = 1;
			while (--k) j *= 2;
			D += j;
			while (to != a[i]) {
				from = to; to = a[i];
				while ((ptr = bsearch(&to, r[from-1], 20, sizeof(int), intcmp)) == NULL) { --to; }
				k = (ptr-r[from-1])+1;
				j = 1;
				while (--k) j *= 2;
				D += j;
			}
		} else {
			from = a[i]; to = b[i];
			while ((ptr = bsearch(&to, r[from-1], 20, sizeof(int), intcmp)) == NULL) { --to; }
			k = (ptr-r[from-1])+1;
			j = 1;
			while (--k) j *= 2;
			D += j;
			while (to != b[i]) {
				from = to; to = b[i];
				while ((ptr = bsearch(&to, r[from-1], 20, sizeof(int), intcmp)) == NULL) { --to; }
				k = (ptr-r[from-1])+1;
				j = 1;
				while (--k) j *= 2;
				D += j;
			}
		}
		printf("%d\n", D);
	}
	return 0;
}
