#include <bits/stdc++.h>
using namespace std;
int x[100005];
int main() {
  int n, l, q, a, b;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l >> q;
  while (q--) {
    int ct = 0;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    while (a < b) {
      a = upper_bound(x + a, x + b + 1, x[a] + l) - x - 1;
      ct++;
    }
    cout << ct << endl;
  }
}
