#include <bits/stdc++.h>
using namespace std;
long long f(long long b, long long n) {
  if (n < b)
    return n;
  else
    return f(b, n / b) + n % b;
}
signed main() {
  long long N;
  cin >> N;
  vector<long long> x(N);
  map<long long, long long> nexter;
  for (long long i = 0; i < N; ++i) {
    cin >> x[i];
    nexter[x[i]] = i;
  }
  map<pair<long long, long long>, long long> shortCut;
  long long L, Q;
  cin >> L >> Q;
  for (long long i = 0; i < Q; ++i) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    --a;
    --b;
    a = x[a];
    b = x[b];
    long long original = x[a];
    long long diff = 0;
    while (a < b) {
      auto it = shortCut.upper_bound({a, b});
      if (it != shortCut.begin() && (--it)->first.first == a &&
          it->first.first - a > L) {
        a = it->first.second;
        diff += it->second;
      } else {
        auto prev = nexter[a];
        auto it = nexter.upper_bound(a + L);
        it--;
        a = it->first;
        diff++;
        shortCut[{original, b}] = diff;
      }
    }
    cout << diff << endl;
  }
}
