#include <bits/stdc++.h>
using namespace std;
int x[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, l, q;
  while (cin >> n) {
    for (int i = (1); i <= (n); i++) cin >> x[i];
    cin >> l >> q;
    for (int i = (1); i <= (q); i++) {
      int a, b;
      cin >> a >> b;
      if (a > b) swap(a, b);
      int t = 0, p = a;
      while (p < b) {
        int tp = p;
        while (tp < b && x[tp] - x[p] <= l) tp++;
        if (x[tp] - x[p] > l) tp--;
        p = tp;
        t++;
      }
      cout << t << endl;
    }
  }
  return 0;
}
