// Slower C++ solution:
#include <bits/stdc++.h>

  

using namespace std;

  

#define rep(i,n) REP(i,0,n)

#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)

#define repr(i, n) REPR(i, n, 0)

#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)

#define pb push_back

#define all(r) r.begin(),r.end()

#define rall(r) r.rbegin(),r.rend()

#define fi first

#define se second

  

typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

 

const int INF = 1e9;

const ll MOD = 1e9 + 7;

double EPS = 1e-8;



const int MAX_N = 1e5+10;

vector<int> d[MAX_N];



int main(){

	int n;

	cin >> n;

	vi x(n);

	rep(i, n) cin >> x[i];

	int l;

	cin >> l;

	rep(i, n) d[i].resize(31);

	rep(i, n) {

		d[i][0] = upper_bound(all(x), x[i]+l) - x.begin();

		d[i][0]--;

	}

	rep(i, 30){

		rep(j, n) d[j][i+1] = d[d[j][i]][i];

	}

	int q;

	cin >> q;

	rep(i, q) {

		int a, b;

		cin >> a >> b;

		a--; b--;

		if(a > b) swap(a, b);

		ll ans = 0LL, nxt = a;

		while(1) {

			if(d[nxt][0] >= b) {

				ans+=1;

				break;

			} 

			auto it = lower_bound(all(d[nxt]), b);

			--it;

			ans += (1LL<<(int)(it - d[nxt].begin()));

			nxt = *it;

		}

		cout << ans << endl;

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.4486352842929553x):
#include <bits/stdc++.h>

  

using namespace std;

  

#define rep(i,n) REP(i,0,n)

#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)

#define repr(i, n) REPR(i, n, 0)

#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)

#define pb push_back

#define all(r) r.begin(),r.end()

#define rall(r) r.rbegin(),r.rend()

#define fi first

#define se second

  

typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

 

const int INF = 1e9;

const ll MOD = 1e9 + 7;

double EPS = 1e-8;





const int MAX_N = 1e5+10;

int nxt[MAX_N][32];



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    vl x(n);

    rep(i, n) cin >> x[i];

    ll L;

    int Q;

    cin >> L >> Q;



    rep(i, n) {

        auto it = upper_bound(all(x), x[i] + L);

        --it;

        nxt[i][0] = it - x.begin();

    }

    REP(j, 1, 32) {

        rep(i, n) {

            nxt[i][j] = nxt[nxt[i][j-1]][j-1];

        }

    }

    rep(q, Q) {

        ll a, b;

        cin >> a >> b;

        --a;

        --b;

        if(a > b) swap(a, b);

        ll ans = 0LL;

        int cur = a;

        while(cur < b) {

            rep(i, 32) {

                if(nxt[cur][i] >= b) {

                    if(i == 0) {

                        ans += 1;

                        cur = nxt[cur][i];

                    }

                    else {

                        ans += (1LL<<(i-1));

                        cur = nxt[cur][i-1];

                    }

                    break;

                }

            }

            // cout << " " << cur << " -> " << nxt[cur][i] << " " << (1LL<<i) << "day ("  << i << ")" << '\n'; 

        }

        // cout << a << " -> " << b << " (" << cur<<")" << '\n';

        cout << ans << '\n';

    }

    return 0;

}