#include <bits/stdc++.h>
using namespace std;
long long N, L, Q;
long long x[100005];
long long a[100005];
long long b[100005];
vector<long long> vec;
long long cal(long long s, long long g) {
  if (s > g) {
    swap(s, g);
  }
  long long now = s;
  long long ret = 0;
  while (now < g) {
    long long lim = now + L;
    vector<long long>::iterator it = upper_bound(vec.begin(), vec.end(), lim);
    it--;
    now = (*it);
    ret++;
  }
  cout << ret << endl;
  return ret;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    vec.push_back(x[i]);
  }
  cin >> L >> Q;
  sort(vec.begin(), vec.end());
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < Q; i++) {
    cal(x[a[i] - 1], x[b[i] - 1]);
  }
}
