#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main() {
  ll n;
  cin >> n;
  vl x(n);
  for (ll i = 0, i_len = (n); i < i_len; ++i) cin >> x[i];
  ll l, q;
  cin >> l >> q;
  vector<vl> r(20, vl(n));
  for (ll i = 0, i_len = (n); i < i_len; ++i)
    r[0][i] = upper_bound(begin(x), end(x), x[i] + l) - x.begin() - 1;
  for (ll k = 0, k_len = (19); k < k_len; ++k)
    for (ll i = 0, i_len = (n); i < i_len; ++i) r[k + 1][i] = r[k][r[k][i]];
  for (ll _ = 0, __len = (q); _ < __len; ++_) {
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    ll ans = 0;
    for (ll k = 19; k >= 0; k--)
      if (r[k][a] <= b) {
        a = r[k][a];
        ans += 1 << k;
        if (a == b) break;
      }
    cout << ans << '\n';
  }
}
