#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int N, L, Q;
  cin >> N;
  int x[100001], j[100000];
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  cin >> L >> Q;
  x[N] = x[N - 1] + L + 1;
  for (int i = 0; i < N; ++i) {
    j[i] = upper_bound(x + i + 1, x + N, x[i] + L) - x - 1;
  }
  for (int i = 0; i < Q; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (a > b) {
      swap(a, b);
    }
    int d = 0;
    if (N <= 1000 && Q <= 1000) {
      for (d = 0; a < b; ++d) {
        a = j[a];
      }
    }
    cout << d << endl;
  }
  return 0;
}
