/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}

const int _ = 100010;

int n, L, q, x[_], nxt[22][_], pre[22][_];

inline int solve(int a, int b) {
	int res = 0;
	if (a < b) {
		for (rg int i = 18; ~i; --i) {
			if (nxt[i + 1][a] > b && nxt[i][a] <= b)
				a = nxt[i][a], res += 1 << i;
			if (a == b) return res;
		}
		return res + 1;
	} else {
		for (rg int i = 18; ~i; --i) {
			if (pre[i + 1][a] < b && pre[i][a] >= b)
				a = pre[i][a], res += 1 << i;
			if (a == b) return res;
		}
		return res + 1;
	}
}

int main() {
	read(n);
	for (rg int i = 1; i <= n; ++i) read(x[i]);
	read(L), read(q);

	for (rg int l, r, ans, i = 1; i <= n; ++i) {
		l = i, r = n;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (x[mid] - x[i] <= L)
				ans = mid, l = mid + 1;
			else
				r = mid - 1;
		}
		nxt[0][i] = ans;
		
		l = 1, r = i;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (x[i] - x[mid] <= L)
				ans = mid, r = mid - 1;
			else
				l = mid + 1;
		}
		pre[0][i] = ans;
	}

	for (rg int j = 1; j <= 19; ++j)
		for (rg int i = 1; i <= n; ++i) {
			nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
			if (nxt[j][i] == 0) nxt[j][i] = n + 1;
			pre[j][i] = pre[j - 1][pre[j - 1][i]];
		}
	
	for (rg int a, b, i = 1; i <= q; ++i)
		read(a), read(b), printf("%d\n", solve(a, b));
	
	return 0;
}
