#include <cstdio>
const int MAXN = 1e5+1;
const int LOGV = 17;
int F[LOGV][MAXN];
int X[MAXN];
int main()
{
	int N, L, Q, i, j, logV, step;
	scanf("%d", &N);
	for(logV=1; (1<<(logV+1))<=N; ++logV);
	for(i=1; i<=N; ++i)
		scanf("%d", X+i);
	scanf("%d", &L);
	for(i=j=1; i<=N; ++i)
	{
		while(j<=N && X[j]-X[i]<=L) ++j;
		F[0][i] = j-1;
	}
	for(i=1; i<=logV; ++i)
		for(j=1; j+(1<<i)-1<=N; ++j)
			F[i][j] = F[i-1][F[i-1][j]];
	scanf("%d", &Q);
	int a, b;
	while (Q--)
	{
		scanf("%d%d", &a, &b);
		if(a > b)
			a ^= b ^= a ^= b;
		step = 0;
		for(i=logV; i>=0; --i)
			if(F[i][a] && F[i][a]<b)
				step += 1<<i,
				a = F[i][a];
		printf("%d\n", step+1);
	}
}