#include <bits/stdc++.h>
using namespace std;
#define int long long

int bs(const int &n, const int &t, const int &a[]){
	int l = 0, h = n-1;
	while (l<=h){
		int mid = (l+h)/2;
		if (a[mid] <= t) l = mid+1;
		else h = mid-1;
	}
	return l-1;
}


signed main(){
	int n, l, q, x, y; cin >> n;
	int a[n];
	for (int i=0; i<n; i++) cin >> a[i];
	cin >> l >> q;
	for (int i=0; i<q; i++){
		cin >> x >> y; x--; y--;
		if (x>y){int tmp = x; x = y; y = tmp;}
		int t = 0;
		while (true){
			int k = bs(n, a[x]+l, a);
			t++;
			if (k>=y) break;
			x = k;
		}
		cout << t << endl;
	}
}