#include <bits/stdc++.h>
using namespace std;
int n, l, q, h[100010], a, b, cnt;
struct QUE {
  int a, b, id, ans;
} Q[100010];
bool cmp(QUE x, QUE y) {
  if (x.a == y.a) return x.b < y.b;
  return x.a < y.a;
}
bool cmp2(QUE x, QUE y) { return x.id < y.id; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", h + i);
  scanf("%d%d", &l, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    Q[i].a = a, Q[i].b = b;
    Q[i].id = i;
  }
  sort(Q, Q + q, cmp);
  for (int i = 0, j; i < q; i = j) {
    int now = Q[i].a, cnt = 0;
    vector<int> T;
    for (j = i; Q[i].a == Q[j].a; j++) T.push_back(Q[j].b);
    for (int c = 0; c < T.size(); c++) {
      while (now < T[c]) {
        now = (int)(upper_bound(h + 1, h + n + 1, h[now] + l) - h) - 1;
        cnt++;
      }
      Q[i + c].ans = cnt;
    }
  }
  sort(Q, Q + q, cmp2);
  for (int i = 0; i < q; i++) printf("%d\n", Q[i].ans);
  return 0;
}
