#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
int n, a[N], q, L, pos = 1, pref[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = inf * 2;
  cin >> L >> q;
  for (int i = 1; i < n;) {
    pref[pos - 1]++;
    while (a[pos] - a[i] <= L) pos++;
    i = pos - 1;
  }
  for (int i = 1; i <= n; i++) pref[i] += pref[i - 1];
  while (q--) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    cout << pref[r] - pref[l] << endl;
  }
}
