#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> d(n);
  for (long long int i = 0; i < n; i++) {
    cin >> d[i];
  }
  long long int l, q;
  cin >> l;
  cin >> q;
  vector<long long int> a(q);
  vector<long long int> b(q);
  for (long long int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    if (a[i] < b[i]) {
      long long int aa = d[a[i] - 1];
      long long int bb = d[b[i] - 1];
      long long int r = 1;
      while (aa + l < bb) {
        vector<long long int>::iterator ite =
            upper_bound(d.begin(), d.end(), aa + l);
        long long int ii = ite - d.begin();
        ii--;
        aa = d[ii];
        r++;
      }
      cout << r << endl;
    } else {
      long long int aa = d[b[i] - 1];
      long long int bb = d[a[i] - 1];
      long long int r = 1;
      while (aa < bb - l) {
        vector<long long int>::iterator ite =
            lower_bound(d.begin(), d.end(), bb - l);
        long long int ii = ite - d.begin();
        bb = d[ii];
        r++;
      }
      cout << r << endl;
    }
  }
  return 0;
}
