#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int parse[100010][21];
int n;
int a[100010];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	a[n+1] = 1234567890;
	int q;
	scanf("%d", &q);
	for (int i = 1; i <=n; i++)
	{
		int t = upper_bound(a, a + n+1, a[i] + q) - a;
		parse[i][0] = t - 1;
	}
	for (int i = 1; i < 21; i++)
	{
		for (int y = 1; y <=n; y++)
			parse[y][i] = parse[parse[y][i - 1]][i - 1];
	}
	int o;
	scanf("%d", &o);
	while (o--)
	{
		int w, e;
		scanf("%d %d", &w, &e);
		if (w > e)
			swap(w, e);
		int dap = 0;
		for (int i = 20; i >= 0; i--)
		{

			if (parse[w][i] == 0)continue;
			if (parse[w][i] < e)
			{
				dap += (1 << i);
				w = parse[w][i];
			}
		}
		dap++;
		printf("%d\n", dap);
	}
}