#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k, q;
  cin >> n;
  int hotel[n + 2];
  hotel[n + 1] = 2e9;
  for (int i = 1; i <= n; i++) {
    cin >> hotel[i];
  }
  cin >> k;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    int ans = 0;
    int pos = u;
    while (pos < v) {
      int next;
      for (next = pos + 1; next <= v + 1; next++) {
        if (hotel[next] - hotel[pos] > k) break;
      }
      pos = next - 1;
      ans++;
    }
    cout << ans << '\n';
  }
}
