#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> x[i];
  cin >> l >> q;
  vector<int> a(q), b(q);
  for (int(i) = 0; (i) < (q); (i)++) cin >> a[i] >> b[i];
  for (int(i) = 0; (i) < (q); (i)++) {
    int f = a[i] - 1, t = b[i] - 1;
    if (f > t) swap(f, t);
    long long ans = 0;
    for (int(j) = (f); (j) < (t + 1); (j)++) {
      if (x[j] - x[f] > l) {
        ans++, f = j - 1;
      }
      if (j == t && j != f) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
