#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void gn(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <typename T>
inline void gt(T x) {
  if (!x) return;
  gt(x / 10);
  putchar(x % 10 + '0');
}
const long long N = 1e5 + 5;
struct NODE {
  long long i, r, c, num;
} tt, ss;
long long t, n, m, q, ans;
long long MOD = 1e9 + 7, inf = 0x1f1f1f1f;
double eps = 1e-5;
long long f[N], dp[18][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j, k, l, ca = 0, u, v, tmp;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> f[i];
  f[n + 1] = 1e18;
  cin >> m;
  for (tmp = i = 1; i < n; i++) {
    for (j = tmp + 1;; j++)
      if (f[j] - f[i] > m) break;
    tmp = dp[1][i] = j - 1;
  }
  for (i = 2; (1 << i) < n; i++) {
    for (j = 1; j <= n - (1 << i >> 1); j++) {
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  }
  k = i - 1;
  cin >> t;
  while (t--) {
    cin >> u >> v;
    ans = 0;
    if (u > v) swap(u, v);
    for (i = k; i; i--) {
      if (dp[i][u] > v) continue;
      if (dp[i][u]) ans += (1 << i >> 1), u = dp[i][u];
      if (u == v) break;
    }
    while (u < v) {
      ans++;
      u = dp[1][u];
    }
    cout << ans << endl;
  }
  return 0;
}
