#include <bits/stdc++.h>
using namespace std;
struct I {
  I() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} init;
const long long MOD = 1e9 + 7;
const long long INF = 1e16;
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& it : v) is >> it;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (int i = 0, sz = v.size(); i < sz; i++) os << (!i) + " " << v[i];
  return os;
}
int main() {
  int N, Q;
  long long L;
  cin >> N;
  vector<long long> x(N);
  cin >> x;
  cin >> L >> Q;
  vector<int> a(Q), b(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < Q; i++) {
    int res = 0;
    int now = a[i];
    while (now != b[i]) {
      int can = now, cannot = b[i];
      if (a[i] < b[i])
        cannot++;
      else
        cannot--;
      while (abs(cannot - can) > 1) {
        const int mid = (can + cannot) / 2;
        if (abs(x[mid] - x[now]) <= L)
          can = mid;
        else
          cannot = mid;
      }
      res++;
      now = can;
    }
    cout << res << endl;
  }
  return 0;
}
