#include <bits/stdc++.h>
using namespace std;
int l, n, m;
int f[100010][25] = {}, a[100010] = {};
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while ((ch > '9' || ch < '0') && ch != '-') ch = getchar();
  if (ch == '-') w = -1;
  while (ch <= '9' && ch >= '0') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
struct rode {
  int l, r;
} e[100010 * 2] = {};
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  l = read();
  m = read();
  for (int i = 1; i <= m; ++i)
    e[i].l = read(), e[i].r = read(),
    e[i].l <= e[i].r ? 0 : e[i].l ^= e[i].r ^= e[i].l ^= e[i].r;
  for (int i = 1; i <= n; ++i) {
    int k = i;
    while (k <= n && a[k] <= a[i] + l) ++k;
    f[i][0] = k - 1;
  }
  for (int j = 1; j <= 25; ++j) {
    for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  }
  for (int i = 1; i <= m; ++i) {
    int ll = e[i].l, s = 0;
    bool p = 0;
    for (int j = 25; j >= 0; --j)
      if (f[ll][j] <= e[i].r) ll = f[ll][j], s += (1 << j), p = 1;
    if (!p) s = 1;
    printf("%d\n", s);
  }
  return 0;
}
