#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
int main() {
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < (int)(N); i++) cin >> x[i];
  cin >> L >> Q;
  vector<int> a(Q), b(Q);
  for (int i = 0; i < (int)(Q); i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  for (int i = 0; i < (int)(Q); i++) {
    int pos = x[a[i]];
    int cnt = 0;
    while (pos < x[b[i]]) {
      cnt++;
      int tmp = upper_bound((x).begin(), (x).end(), pos + L) - x.begin() - 1;
      pos = x[tmp];
    }
    cout << cnt << endl;
  }
  return 0;
}
