#include <bits/stdc++.h>
using namespace std;
long long N;
long long x[100005];
long long L, Q;
long long a[100005], b[100005];
long long calc(long long u, long long v) {
  long long res = 0;
  long long cur = u;
  while (x[cur] < x[v]) {
    cur = upper_bound(x, x + N, x[cur] + L) - x - 1;
    res++;
  }
  return res;
}
void solve() {
  for (int i = 0; i < Q; i++) {
    cout << calc(min(a[i], b[i]), max(a[i], b[i])) << endl;
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  solve();
  return 0;
}
