#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <class T1, class T2>
void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using Pi = pair<long long, long long>;
using Tapris = tuple<long long, long long, long long>;
using vint = vector<long long>;
const long long inf = 1LL << 55;
const long long mod = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  long long n;
  cin >> n;
  vint x(n);
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> x[i];
  long long l;
  cin >> l;
  vector<vint> far(22, vint(n, -1));
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    long long lb = i, ub = n;
    while (lb + 1 < ub) {
      long long mb = (lb + ub) / 2;
      if (x[i] + l >= x[mb])
        lb = mb;
      else
        ub = mb;
    }
    far[0][i] = lb;
  }
  for (long long i = (long long)(0); i < (long long)(21); i++) {
    for (long long j = (long long)(0); j < (long long)(n); j++) {
      far[i + 1][j] = far[i][far[i][j]];
    }
  }
  vint pow2(22);
  pow2[0] = 1;
  for (long long i = (long long)(0); i < (long long)(21); i++)
    pow2[i + 1] = pow2[i] * 2;
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    --a, --b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long i = 21; i >= 0; --i) {
      if (far[i][a] <= b) {
        ans += pow2[i];
        a = far[i][a];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
