#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int rw[100010];
vector<int> W[100010];

int main(){
	for (int i = 0;i < 100010;i++)rw[i] = -1;
	ll N, L;
	cin >> N;
	vector<ll> X(N);
	for (int i = 0;i < N;i++)
		cin >> X[i];
	cin >> L;
	for (int j = 0;j < N;j++) {
		if (rw[j] >= 0)continue;
		for (int i = j;i < N;) {
			W[j].push_back(i);
			if (rw[i] >= 0)break;
			rw[i] = j;
			auto it = upper_bound(all(X), X[i] + L);
			it--;
			i = it - X.begin();
		}
	}

	//for (int i = 0;i < N;i++)cout << rw[i] << " ";

	ll Q, a, b, c, d, ans = 0;
	cin >> Q;
	for (int i = 0;i < Q;i++) {
		ans = 0;
		cin >> a >> b;
		if (a > b)swap(a, b);
		a--;b--;
		c = rw[a];
		while (1) {
			auto it = W[c].end();
			it--;
			d = *it;
			if (d >= b)break;
			ans += it - find(all(W[c]), a);
			//cout << ans << endl;
			a = d;
			c = rw[a];
		}
		auto it1 = find(all(W[c]), a);
		auto it2 = lower_bound(all(W[c]), b);
		ans += it2 - it1;
		cout << ans << endl;
	}
}
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 100100;
const int LOG = 17;
int n, L, q;
int Q[N][2];
int ANS[N];
int a[N];
int b[LOG][N];

void solve() {
	int p = 0;
	for (int i = 0; i < n; i++) {	
		while(p + 1 < n && a[p + 1] - a[i] <= L) p++;
		b[0][i] = p;
	}
	for (int k = 0; k < LOG - 1; k++)
		for (int i = 0; i < n; i++)
			b[k + 1][i] = b[k][b[k][i]];
	for (int i = 0; i < q; i++) {
		int v = Q[i][0], u = Q[i][1];
		if (v > u) continue;
		int ans = 0;
		for (int k = LOG - 1; k >= 0; k--) {
			if (b[k][v] < u) {
				v = b[k][v];
				ans += 1 << k;
			}
		}
		ANS[i] = ans + 1;
	}
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	scanf("%d%d", &L, &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &Q[i][0], &Q[i][1]);
		Q[i][0]--;
		Q[i][1]--;
	}
	solve();
	for (int i = 0; i < q; i++) {
		Q[i][0] = n - 1 - Q[i][0];
		Q[i][1] = n - 1 - Q[i][1];
	}
	reverse(a, a + n);
	for (int i = 0; i < n; i++)
		a[i] *= -1;
	solve();
	for (int i = 0; i < q; i++)
		printf("%d\n", ANS[i]);

	return 0;
}
