#include <bits/stdc++.h>
template <class T>
bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
ll tugi[20][101010];
void Main() {
  ll N;
  cin >> N;
  vector<ll> x(N);
  for (ll i = 0; i < N; i++) cin >> x[i];
  ll L;
  cin >> L;
  ll Q;
  cin >> Q;
  for (ll i = 0; i < N; i++) {
    ll tu = upper_bound((x).begin(), (x).end(), x[i] + L) - x.begin();
    tu--;
    tugi[0][i] = tu;
  }
  for (ll i = 0; i < 20; i++) {
    for (ll j = 0; j < N; j++) {
      tugi[i + 1][j] = tugi[i][tugi[i][j]];
    }
  }
  while (Q--) {
    ll a, b;
    cin >> a >> b;
    --a, --b;
    if (a > b) swap(a, b);
    ll ans = 0;
    for (ll i = 19; i >= 0; i--) {
      if (tugi[i][a] < b) {
        ans += (1 << i);
        a = tugi[i][a];
      }
    }
    ++ans;
    cout << ans << "\n";
  }
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
