#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
using namespace std;
const int N = 1e5 + 5, M = N * N, OO = 0x3f3f3f3f;
int n, l, q, arr[N], x, y;
int lst, far, d;
struct query {
  int x, y, qnum, ans;
} qarr[N];
bool cmp(query a, query b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int mnroot(int t) {
  int cur = far, dis = d, idx;
  while (cur < t) {
    idx = lower_bound(arr, arr + n, arr[cur] + l) - arr;
    if (idx == n) {
      far = n - 1;
      d = dis + 1;
      return d;
    }
    if (arr[idx] > arr[cur] + l) idx--;
    if (idx >= t) {
      far = idx;
      d = dis + 1;
      return d;
    }
    cur = idx;
    dis++;
  }
  return d;
}
bool cmp2(query a, query b) { return a.qnum < b.qnum; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  scanf("%d%d", &l, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &x, &y);
    x--, y--;
    qarr[i].x = min(x, y), qarr[i].y = max(x, y), qarr[i].qnum = i;
  }
  sort(qarr, qarr + q, cmp);
  lst = far = -1;
  for (int i = 0; i < q; i++) {
    if (qarr[i].x != lst) {
      lst = far = qarr[i].x;
      d = 0;
    }
    qarr[i].ans = mnroot(qarr[i].y);
  }
  sort(qarr, qarr + q, cmp2);
  for (int i = 0; i < q; i++) {
    printf("%d\n", qarr[i].ans);
  }
}
