#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MX = 2e5 + 5;
int n, L, x[MX], q, prefix[MX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> x[i];
  cin >> L;
  prefix[0] = 0;
  int r;
  for (r = 1; r < n && x[r] - x[0] <= L; ++r) prefix[r] = 1;
  for (int l = 0; r < n; ++r) {
    while (x[r] - x[l] > L) ++l;
    prefix[r] = prefix[l] + 1;
  }
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    cout << max(1, prefix[b] - prefix[a]) << '\n';
  }
}
