#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vll x(n);
  for (ll i = 0; i < (ll)n; ++i) cin >> x[i];
  ll l, q;
  cin >> l >> q;
  vvll doubling(n, vll(31, 0));
  for (ll i = 0; i < (ll)n; ++i) {
    ll j = 0;
    while (j < n && x[j] - x[i] <= l) j++;
    doubling[i][0] = j - 1;
  }
  cout << '\n';
  for (ll j = 0; j < (ll)30; ++j) {
    for (ll i = 0; i < (ll)n; ++i) {
      doubling[i][j + 1] = doubling[doubling[i][j]][j];
    }
  }
  for (ll _ = 0; _ < (ll)q; ++_) {
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    ll ans = 0;
    for (ll i = 30; i >= 0; i--) {
      if (doubling[a][i] < b) {
        ans += 1 << i;
        a = doubling[a][i];
      }
    }
    cout << ans + 1 << '\n';
  }
  return 0;
}
