#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, L, Q;
  cin >> N;
  vector<int64_t> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  cin >> L >> Q;
  vector<int64_t> ikeru(N);
  int next = 0;
  for (int i = 0; i < N; ++i) {
    while (next < N && x[next] <= x[i] + L) {
      ++next;
    }
    ikeru[i] = next - 1;
  }
  vector<int64_t> vec(N);
  int time = 0;
  int basyo = 0;
  for (int i = 0; i < N; ++i) {
    vec[i] = time;
    if (basyo == i) {
      basyo = ikeru[i];
      ++time;
    }
  }
  for (int t = 0; t < Q; ++t) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (a > b) swap(a, b);
    if (a == b) {
      cout << 0 << endl;
    } else {
      cout << max(int64_t(1), vec[b] - vec[a]) << endl;
    }
  }
}
