#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-8;
const int inf = 1e8;
int main() {
  int n;
  cin >> n;
  vector<long long> in(n);
  for (int i = 0; i < n; i++) cin >> in[i];
  int l;
  cin >> l;
  int q;
  cin >> q;
  if (n > 2000 || q > 2000) return 0;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    int out = 0;
    int t = a;
    while (in[a] < in[b]) {
      out++;
      a = upper_bound(in.begin(), in.end(), in[a] + l) - in.begin();
      a--;
    }
    cout << out << endl;
  }
}
