#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
signed main() {
  int n;
  cin >> n;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  int l;
  cin >> l;
  const int LOG = 18;
  array<vector<int>, LOG + 1> nxt;
  for (int i = 0; i <= LOG; i++) nxt[i].resize(n);
  for (int j = 0; j < n; j++)
    nxt[0][j] = --upper_bound(xs.begin(), xs.end(), xs[j] + l) - xs.begin();
  for (int i = 0; i < LOG; i++)
    for (int j = 0; j < n; j++) nxt[i + 1][j] = nxt[i][nxt[i][j]];
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int k = LOG; k >= 0; k--)
      if (nxt[k][a] <= b) ans += 1 << k, a = nxt[k][a];
    cout << ans << "\n";
  }
  cout << flush;
  return 0;
}
