#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long sum = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return f * sum;
}
const long long N = 100005;
struct node {
  long long pre, nxt, to, sp;
} a[N];
struct ques {
  long long l, r, ans;
} q[N];
long long n, m, L, p[N];
long long bl[N], gap;
signed main() {
  n = read();
  gap = sqrt(n);
  for (long long i = 1; i <= n; i++) p[i] = read();
  for (long long i = 1; i <= n; i++) bl[i] = (i - 1) / gap + 1;
  L = read();
  m = read();
  for (long long i = 1; i <= m; i++) q[i].l = read(), q[i].r = read();
  for (long long i = 1; i <= m; i++)
    if (q[i].l > q[i].r) swap(q[i].l, q[i].r);
  for (long long i = 1; i <= n; i++) {
    a[i].nxt = upper_bound(p + 1, p + n + 1, p[i] + L) - p - 1;
  }
  for (long long i = 1; i <= n; i++) {
    a[i].to = i;
    while (bl[a[i].to] == bl[i] && bl[a[i].to] != bl[n])
      a[i].to = a[a[i].to].nxt, a[i].sp++;
  }
  for (long long i = 1; i <= m; i++) {
    long long l = q[i].l, r = q[i].r;
    while (bl[l] != bl[r] && bl[l] != bl[n]) q[i].ans += a[l].sp, l = a[l].to;
    while (l < r) q[i].ans++, l = a[l].nxt;
  }
  for (long long i = 1; i <= m; i++) printf("%lld\n", q[i].ans);
  return 0;
}
