/*--------------------------------
  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[_], pre[_];

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

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[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[i] = ans;
	}
	
	for (rg int a, b, i = 1; i <= q; ++i)
		read(a), read(b), printf("%d\n", solve(a, b));
	
	return 0;
}
