#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
inline int R() {
  int rt = 0;
  bool isn = false;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar()) isn = ch == '-' ? true : isn;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) rt = rt * 10 + ch - '0';
  return isn ? -rt : rt;
}
struct Hotel {
  int pos, id;
} a[MAXN];
int dp[19][MAXN], rp[MAXN];
bool Cmp(Hotel t1, Hotel t2) { return t1.pos < t2.pos; }
int main() {
  int n = R(), lm = log2(n);
  for (int i = 1; i <= n; ++i) a[i].pos = R(), a[i].id = i;
  sort(a + 1, a + n + 1, Cmp);
  for (int i = 1; i <= n; ++i) rp[a[i].id] = i;
  int l = R();
  for (int i = 1; i <= n; ++i) {
    int nl = i, nr = n;
    while (nl <= nr) {
      int mid = nl + nr >> 1;
      if (a[mid].pos - a[i].pos <= l)
        dp[0][i] = mid, nl = mid + 1;
      else
        nr = mid - 1;
    }
  }
  for (int i = 1; i <= lm; ++i)
    for (int j = 1; j <= n; ++j) dp[i][j] = dp[i - 1][dp[i - 1][j]];
  for (int q = R(); q; --q) {
    int l = rp[R()], r = rp[R()];
    if (l > r) swap(l, r);
    int ans = 0;
    for (int i = log2(r - l); i >= 0; --i)
      if (a[dp[i][l]].pos <= a[r].pos) ans += 1 << i, l = dp[i][l];
    printf("%d\n", ans);
  }
  return 0;
}
