#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  for (; !isalnum(ch); ch = getchar())
    ;
  for (; isalnum(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x;
}
const int xx = 1e5 + 1612;
int r[xx], l[xx], to[xx], lea[xx], bel[xx];
int x[xx], n, L, m;
inline void init() {
  n = read();
  for (register int i = 1; i <= n; ++i) x[i] = read();
  L = read();
  m = sqrt(n);
  for (register int i = 1; i <= n; ++i) {
    bel[i] = (i - 1) / m + 1;
    if (bel[i] != bel[i - 1]) l[bel[i]] = i;
    r[bel[i]] = i;
  }
}
inline void pre() {
  for (register int i = m; i >= 1; --i) {
    lea[r[i]] = 1;
    int j = r[i];
    while (j <= n && x[j] - x[r[i]] <= L) ++j;
    to[r[i]] = j == n ? n : j - 1;
    for (register int k = r[i] - 1; k >= l[i]; --k) {
      while (x[j] - x[k] > L) --j;
      lea[k] = (j > r[i]) ? 1 : lea[j] + 1;
      to[k] = (j > r[i]) ? j : to[j];
    }
  }
}
inline void sol(int a, int b) {
  if (a > b) swap(a, b);
  int j = a, ans = 0;
  while (bel[j] < bel[b]) ans += lea[j], j = to[j];
  while (j < b) {
    int i = j + 1;
    while (i <= n && x[i] - x[j] <= L) ++i;
    j = i - 1;
    ++ans;
  }
  printf("%d\n", ans);
}
signed main() {
  init();
  pre();
  int T = read();
  while (T--) sol(read(), read());
  return 0;
}
