#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int K = 20;
int stepmem[N * K * 5], remmem[N * K * 5];
int suc[N], x[N];
int gap;
int memcnt = 0;
int *step[N * 4];
int *rem[N * 4];
void build(int nd, int l, int r) {
  step[nd] = stepmem + memcnt;
  rem[nd] = remmem + memcnt;
  memcnt += (r - l + 1);
  int md = r - l;
  step[nd][md] = 1;
  rem[nd][md] = r;
  for (int i = md - 1; i >= 0; i--) {
    if (suc[i + l] > r) {
      step[nd][i] = 1;
      rem[nd][i] = i + l;
    } else {
      step[nd][i] = step[nd][suc[i + l] - l] + 1;
      rem[nd][i] = rem[nd][suc[i + l] - l];
    }
  }
  if (l == r) return;
  md = (l + r) >> 1;
  nd <<= 1;
  build(nd, l, md);
  build(nd ^ 1, md + 1, r);
}
pair<int, int> query(int nd, int l, int r, int tr, int ph) {
  if (ph == r) {
    return {step[nd][tr - l], rem[nd][tr - l]};
  }
  int m = (l + r) >> 1;
  int cc = (nd << 1);
  if (ph <= m) return query(cc, l, m, tr, ph);
  if (tr > m) return query(cc ^ 1, m + 1, r, tr, ph);
  auto p = query(cc, l, m, tr, m);
  int u = suc[p.second];
  int tmp = p.first;
  if (u >= ph) return p;
  p = query(cc ^ 1, m + 1, r, u, ph);
  return {tmp + p.first, p.second};
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", x + i);
  int q;
  scanf("%d%d", &gap, &q);
  for (int i = n, j = n; i >= 1; i--) {
    while (j >= i && x[i] + gap < x[j]) j--;
    suc[i] = j;
  }
  build(1, 1, n);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    auto p = query(1, 1, n, u, v);
    int ans = p.first;
    if (p.second == v) ans--;
    printf("%d\n", ans);
  }
  return 0;
}
