#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  int l;
  cin >> l;
  int q;
  cin >> q;
  vector<int> a(q), b(q);
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  int M = 20;
  vector<vector<int>> c(n, vector<int>(M));
  for (int i = 0; i < n; ++i) {
    int lb = -1, ub = n;
    while (ub - lb > 1) {
      int mid = (ub + lb) / 2;
      (x[mid] <= x[i] + l ? lb : ub) = mid;
    }
    c[i][0] = lb;
  }
  for (int j = 1; j <= M - 1; ++j) {
    for (int i = 0; i < n; ++i) {
      c[i][j] = c[c[i][j - 1]][j - 1];
    }
  }
  vector<int> pow2(M + 1);
  pow2[0] = 1;
  for (int i = 0; i < M; ++i) {
    pow2[i + 1] = pow2[i] * 2;
  }
  for (int i = 0; i < q; ++i) {
    if (a[i] > b[i]) swap(a[i], b[i]);
    int res = 0;
    while (1) {
      int idx = 0;
      while (c[a[i]][idx] <= b[i]) idx++;
      if (idx == 0) {
        res += pow2[idx];
        break;
      } else {
        res += pow2[idx - 1];
        if (c[a[i]][idx - 1] == b[i]) break;
      }
      a[i] = c[idx - 1][0];
    }
    cout << res << "\n";
  }
  return 0;
}
