#include <bits/stdc++.h>
using namespace std;
int n, l, q;
int main() {
  cin >> n;
  vector<int> x(n + 1);
  for (int i = 0; i < n; i++) scanf("%d", &x[i + 1]);
  cin >> l >> q;
  vector<int> a(q), b(q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &a[i], &b[i]);
    if (a[i] > b[i]) swap(a[i], b[i]);
    int x1 = x[a[i]], x2 = x[b[i]];
    int res = 0;
    while (true) {
      int ind = upper_bound(x.begin() + a[i], x.begin() + b[i] + 1, x1 + l) -
                x.begin();
      res++;
      if (ind == x.size() || ind - 1 >= b[i]) break;
      x1 = x[ind - 1];
      a[i] = ind - 1;
    }
    printf("%d\n", res);
  }
}
