#include <bits/stdc++.h>

using namespace std;

map<int, int> num, pos;
set<int> s;
vector<int> v;

const int N = 1e5+10;
const int k = 30;

int up[N][k];
int L;
void calc(int i) {
	//cout << "this->" << *s.lower_bound(-(v[i]+L)) << endl;
	up[i][0] = num[*s.lower_bound(-(v[i]+L))];
	//cout << up[i][0] << endl;
	for(int j = 1; j < k; j++) {
		up[i][j] = up[up[i][j-1]][j-1];
	}
	/*cout << "i=" << i << ": " <<  endl;
	for(int j = 0; j < k; j++) cout << "k=" << j << " " << up[i][j] << endl;
	cout << endl;
	*/
}

int solve(int a, int b) {
	if(a>b) swap(a, b);
	int sum = 0;
	int cur = a;
	while(cur != b) {
		for(int j = 0; j < k-1; j++) {
			if(up[cur][j] >= b) {
				if(j==0) {
					sum++;
					cur = b;
				} else {
					cur = up[cur][j-1];
					sum += (1<<(j-1));
				}
				break;
			}
		}
	}

	return sum;
}

int main() {
	int n; cin >> n;
	v.resize(n+1);
	int cnt = 1;
	for(int i = 1; i <= n; i++) {
		int xi; cin >> xi;
		num[-xi] = cnt;
		pos[cnt] = xi;
		cnt++;
		s.insert(-xi);
		v[i] = xi;
	}
	cin >> L;
	for(int i = 0; i < k; i++) up[n+1][i] = n; 
	for(int i = n; i > 0; i--) {
		calc(i);
	}

	int q; cin >> q;
	while(q--) {
		int a, b; cin >> a >> b;
		cout << solve(a, b) << "\n";
	}
}
// Date: 2020-03-19

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout<<#x<<" = "<<x<<endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int r[N][30], x[N], n, L, Q, dep;

void init() {
    rep(i, 1, n) r[i][0] = upper_bound(x+i, x+n+1, x[i]+L)-x-1;
    rep(d, 1, 20) {
        rep(i, 1, n) {
            r[i][d] = r[r[i][d-1]][d-1];
        }
    }
}

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> x[i];
    cin >> L >> Q;
    init();
    while(Q--) {
        int u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        int ans = 0;
        for(int i = 20; i >= 0; --i) {
            if(r[u][i] < v) {
                ans += (1 << i);
                u = r[u][i];
            }
        }
        cout << ans+1 << '\n';
    }

    return 0;
}