#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, l, q, x, y;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  cin >> l >> q;
  for (long long i = 0; i < q; i++) {
    cin >> x >> y;
    x--;
    y--;
    if (x > y) {
      long long tmp = x;
      x = y;
      y = tmp;
    }
    long long t = 0;
    while (true) {
      long long k = (upper_bound(a, a + n, a[x] + l)) - a - 1;
      t++;
      if (k >= y) break;
      x = k;
    }
    cout << t << endl;
  }
}
