#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int 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 int N = 100005;
struct node {
  int l, r, pre, nxt;
} a[N];
struct ques {
  int l, r, id, ans;
} q[N];
int n, m, L, p[N];
inline bool cmp(ques a, ques b) { return a.l != b.l ? a.l < b.l : a.r < b.r; }
inline bool cmp1(ques a, ques b) { return a.id < b.id; }
signed main() {
  n = read();
  for (int i = 1; i <= n; i++) p[i] = read();
  L = read();
  m = read();
  for (int i = 1; i <= m; i++) q[i].l = read(), q[i].r = read();
  for (int i = 1; i <= m; i++) q[i].id = i;
  for (int i = 1; i <= m; i++)
    if (q[i].l > q[i].r) swap(q[i].l, q[i].r);
  for (int i = 1; i <= n; i++) {
    int k = p[i] + L;
    k = upper_bound(p + 1, p + n + 1, k) - p - 1;
    a[i].nxt = k;
    if (!a[k].l || i < a[k].l) a[k].l = i;
    a[k].r = max(a[k].r, i);
    a[i].pre = upper_bound(p + 1, p + n + 1, p[i] - L) - p;
  }
  for (int i = 1; i <= m; i++) {
    if (q[i].l < q[i].r) {
      while (q[i].l < q[i].r) q[i].l = a[q[i].l].nxt, q[i].ans++;
    } else {
      while (q[i].r > q[i].l) q[i].r = a[q[i].r].pre, q[i].ans++;
    }
  }
  sort(q + 1, q + m + 1, cmp1);
  for (int i = 1; i <= m; i++) printf("%d\n", q[i].ans);
  return 0;
}
