#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> Xs;
int L, Q;
int go_next(int cur) {
  auto itr = lower_bound((Xs).begin(), (Xs).end(), cur + L);
  if (*itr == cur + L) {
    return distance(Xs.begin(), itr);
  } else {
    return distance(Xs.begin(), itr) - 1;
  }
}
int main(void) {
  cin.sync_with_stdio(false);
  cin >> N;
  Xs.resize(N);
  for (int n = 0; n < (int)(N); ++n) cin >> Xs[n];
  cin >> L >> Q;
  for (int q = 0; q < (int)(Q); ++q) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (b < a) swap(a, b);
    int s = Xs[a];
    int g = Xs[b];
    int ans = 0;
    while (1) {
      ++ans;
      auto nxt = go_next(s);
      s = Xs[nxt];
      if (s >= g) break;
    }
    cout << ans << endl;
  }
  return 0;
}
