#include <bits/stdc++.h>
using namespace std;
int n, l, q, a, b, tot, size, x[100000 + 5], nxt[100000 + 5], last[100000 + 5],
    cntb[100000 + 5], block[100000 + 5];
int read() {
  char c;
  int x = 0, f = 1;
  c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
int main() {
  n = read(), size = sqrt(n), tot = ceil(1.0 * n / size);
  for (int i = 1; i <= n; ++i) x[i] = read();
  l = read();
  for (int i = 1; i <= n; ++i) {
    int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
    if (x[pos] < x[i] + l)
      last[i] = n + 1;
    else
      last[i] = pos - 1;
  }
  block[n + 1] = tot + 1;
  for (int i = 1; i <= n; ++i) block[i] = i / size + 1;
  for (int i = 1; i <= n; ++i) {
    int pos = i, cnt = 0;
    while (block[pos] == block[i]) pos = last[pos], ++cnt;
    cntb[i] = cnt, nxt[i] = pos;
  }
  q = read();
  while (q--) {
    a = read(), b = read();
    if (a > b) swap(a, b);
    int pos = a, ans = 0;
    while (block[pos] != block[b]) ans += cntb[pos], pos = nxt[pos];
    while (pos < b) pos = last[pos], ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
