#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  ll n, l;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < (int)n; i++) cin >> x[i];
  cin >> l;
  ll nibeki = 1;
  while (1) {
    if ((1 << nibeki) >= n) break;
    nibeki++;
  }
  vector<vector<ll>> par(n, vector<ll>(nibeki, n - 1));
  for (int i = 0; i < (int)n; i++) {
    par[i][0] = upper_bound(x.begin(), x.end(), x[i] + l) - 1 - x.begin();
  }
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)nibeki - 1; j++) {
      par[i][j + 1] = par[par[i][j]][j];
    }
  }
  ll q;
  cin >> q;
  vector<ll> a(q), b(q);
  for (int i = 0; i < (int)q; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
    ll ng = 0, ok = n;
    while ((ok - ng) > 1) {
      ll mid = (ng + ok) / 2;
      ll now = a[i];
      for (int j = 0; j < (int)nibeki; j++) {
        if ((mid >> j) & 1) {
          now = par[now][j];
        }
      }
      if (now >= b[i])
        ok = mid;
      else
        ng = mid;
    }
    cout << ok << endl;
  }
  return 0;
}
