
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
using ll = long long;

ll n;
ll x[123456];//n
ll l;
ll q;
ll a[123456], b[123456];//q

ll lbar[123456];//n
ll rbar[123456];//n

vector<ll> lgraph[123456];

ll dist[123456];
int bfs(int v1, int v2)
{
	queue<ll> que;
	memset(dist, 0xFF, sizeof(ll) * n);
	que.push(v1);
	while (!que.empty())
	{
		ll vn = que.front(); que.pop();
		for (ll vx : lgraph[vn])
		{
			if (vx == v2)return dist[vn] + 1;
			if (dist[vx] == -1)
			{
				dist[vx] = min(dist[vn] + 1, dist[vx]);
				que.push(vx);
			}
		}
	}
	return 0;
}

int main()
{
	scanf("%lld",&n);
	for (int i = 0; i < n; ++i)scanf("%lld", x + i);
	scanf("%lld %lld", &l, &q);
	for (int j = 0; j < q; ++j)
	{
		scanf("%lld %lld", a + j, b + j);
		--a[j]; --b[j];
	}
	for (int i = 0; i < n; ++i)
	{
		lbar[i] = lower_bound(x, x + i + 1, x[i] - l) - x;
		rbar[i] = max(upper_bound(x + i, x + n, x[i] + l) - x - 1, i);
	}
	for (int i = 0; i < n; ++i)
	{
		for (int vert = lbar[i]; vert < i;++vert)
		{
			lgraph[vert].push_back(i);
			lgraph[i].push_back(vert);
		}
	}
	for (int j = 0; j < q; ++j)
	{
		ll ans = bfs(a[j], b[j]);
		printf("%lld\n",ans);
	}


	return 0;
}