#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int(i) = 0; (i) < (int)(n); (i)++) cin >> x[i];
  int l;
  cin >> l;
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    vector<int>::iterator it;
    it = x.begin() + a;
    while (*it < x[b]) {
      ans++;
      it = upper_bound((x).begin(), (x).end(), (*it) + l);
      it--;
    }
    cout << ans << endl;
  }
  return 0;
}
