#include <bits/stdc++.h>
using namespace std;
int x[100000 + 1];
int n, l;
int dp[100000 + 1][17 + 1];
inline void make_dp() {
  for (int i = 1; i < n; i++) {
    int rez = i;
    for (int pas = 1 << 16; pas; pas >>= 1)
      if (rez + pas <= n && x[rez + pas] - x[i] <= l) rez += pas;
    dp[i][0] = rez;
  }
  for (int lg = 1; (1 << lg) <= n; lg++)
    for (int i = 1; i <= n; i++) {
      dp[i][lg] = dp[dp[i][lg - 1]][lg - 1];
      if (dp[i][lg] == 0) dp[i][lg] = n + 1;
    }
}
int main() {
  ios::sync_with_stdio(false);
  int i, q, a, b, pas;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> x[i];
  cin >> l >> q;
  make_dp();
  while (q > 0) {
    q--;
    cin >> a >> b;
    if (a > b) std::swap(a, b);
    int ans = 0;
    while (a != b) {
      pas = 1;
      while (pas < 17 && dp[a][pas] <= b) pas++;
      a = dp[a][pas - 1];
      ans += (1 << (pas - 1));
    }
    cout << ans << endl;
  }
  return 0;
}
