#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const int N = 100000 + 10;
int n, lim, Q;
int x[N], L[17][N], R[17][N];
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i) x[i] = read();
  x[n + 1] = 2e9;
  lim = read();
  for (register int i = 1, p = 0; i <= n; ++i) {
    while (x[i] - x[p] > lim) ++p;
    L[0][i] = p;
  }
  for (register int i = n, p = n + 1; i >= 1; --i) {
    while (x[p] - x[i] > lim) --p;
    R[0][i] = p;
  }
  for (register int i = 1; i <= 16; ++i)
    for (register int j = 1; j <= n; ++j)
      L[i][j] = L[i - 1][L[i - 1][j]], R[i][j] = R[i - 1][R[i - 1][j]];
  Q = read();
  while (Q--) {
    int x = read(), y = read(), ans = 0;
    if (x < y) {
      for (register int i = 16; ~i; --i)
        if (R[i][x] <= y) x = R[i][x], ans += (1 << i);
    } else {
      for (register int i = 16; ~i; --i)
        if (L[i][x] >= y) x = L[i][x], ans += (1 << i);
    }
    if (x != y) ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
