//変数名を長くしても伝わらなければ意味がないのじゃ
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
 
int ______________________________________;
int kokoropyonpyonmatchi[100000];
int kangaerufurisite[100001];
int l;
int q;
int mutyotthikaduityaeeeeeeeeee, thikaduityaeeeeeeeeee;
 
int unkonokoun[20][100000];
int nyanyanyanyanyanyanyanyanyanya[20][100000];
 
int dist(int l, int r) {
	if (l > r) swap(l, r);
	return kokoropyonpyonmatchi[r] - kokoropyonpyonmatchi[l];
}
 
bool checkL(int mid) {
	int i = 19;
	int pos = mutyotthikaduityaeeeeeeeeee;
	
	while (i >= 0) {
		if ((mid >> i) % 2 == 1) pos = nyanyanyanyanyanyanyanyanyanya[i][pos];
		i--;
	}
	return (pos <= thikaduityaeeeeeeeeee);
}
 
bool checkR(int mid) {
	int i = 19;
	int pos = mutyotthikaduityaeeeeeeeeee;
	
	while (i >= 0) {
		if ((mid >> i) % 2 == 1) pos = unkonokoun[i][pos];
		i--;
	}
	return (pos >= thikaduityaeeeeeeeeee);
}
 
bool check(int mid) {
	if (mutyotthikaduityaeeeeeeeeee >= thikaduityaeeeeeeeeee) return checkL(mid);
	return checkR(mid);
}
 
signed main() {
	int i, j;
	
	cin >> ______________________________________;
	for (i = 0; i < ______________________________________; i++) cin >> kokoropyonpyonmatchi[i];
	cin >> l;
	
	j = 0;
	for (i = 0; i < ______________________________________; i++) {
		for (j = max(j, i); j < ______________________________________ && dist(i, j) <= l; j++); j--;
		unkonokoun[0][i] = j;
	}
	for (i = 1; i < 20; i++) {
		for (j = 0; j < ______________________________________; j++) {
			unkonokoun[i][j] = unkonokoun[i-1][unkonokoun[i-1][j]];
		}
	}
	
	j = ______________________________________ - 1;
	for (i = ______________________________________ - 1; i >= 0; i--) {
		for (j = min(j, i); j >= 0 && dist(i, j) <= l; j--); j++;
		nyanyanyanyanyanyanyanyanyanya[0][i] = j;
	}
	for (i = 1; i < 20; i++) {
		for (j = 0; j < ______________________________________; j++) {
			nyanyanyanyanyanyanyanyanyanya[i][j] = nyanyanyanyanyanyanyanyanyanya[i-1][nyanyanyanyanyanyanyanyanyanya[i-1][j]];
		}
	}
	
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> mutyotthikaduityaeeeeeeeeee >> thikaduityaeeeeeeeeee;
		mutyotthikaduityaeeeeeeeeee--;
		thikaduityaeeeeeeeeee--;
		
		int stastasta = 0, toritter = ______________________________________ + 5, mendou;
		while (ed - st >= 2) {
			mendou = (stastasta + toritter) / 2;
			if (check(mendou)) { toritter = mendou; }
			else { stastasta = mendou; }
		}
		cout << toritter << endl;
	}
	return 0;
}