#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
struct FastIO {
  FastIO() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} fastiofastio;
const ll INF = 1LL << 60;
template <class T, class F, ll LOG = 4>
struct doubling {
  vector<vector<T>> nxt;
  doubling(vector<T> xs, F f) : nxt(LOG, vector<T>(xs.size())) {
    for (ll i = (ll)0; i < (ll)xs.size(); ++i) nxt[0][i] = f(xs[i]);
    for (ll k = (ll)1; k < (ll)LOG; ++k)
      for (ll j = (ll)0; j < (ll)xs.size(); ++j)
        nxt[k][j] = nxt[k - 1][nxt[k - 1][j]];
  }
  T query(ll x, ll k) {
    for (ll i = LOG - 1; i >= 0; --i)
      if (k & 1LL << i) x = nxt[i][x];
    return x;
  }
};
int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  for (ll i = (ll)0; i < (ll)n; ++i) cin >> x[i];
  ll l;
  cin >> l;
  vector<ll> xs(n);
  iota(xs.begin(), xs.end(), 0);
  auto f = [&](ll idx) {
    return upper_bound(x.begin(), x.end(), x[idx] + l) - x.begin() - 1;
  };
  doubling<ll, decltype(f)> dbl(xs, f);
  ;
  ll q;
  cin >> q;
  while (q--) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    ;
    ll ret = 0;
    for (ll i = 3; i >= 0; --i) {
      ;
      if (dbl.nxt[i][a] < b) {
        ret += 1LL << i;
        a = dbl.nxt[i][a];
      }
      if (dbl.nxt[0][a] >= b) {
        ret++;
        break;
      }
    }
    cout << ret << endl;
  }
  return 0;
}
