#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, L, q, a, b;
  cin >> n;
  long long x[n], y[n];
  for (long long i = (0); i < (n); i++) {
    cin >> x[i];
  }
  cin >> L >> q;
  for (long long i = (0); i < (n); i++) {
    y[i] = n - 1;
  }
  long long l = 0;
  for (long long r = (1); r < (n); r++) {
    while (x[r] - x[l] > L) {
      y[l] = r - 1;
      l++;
    }
  }
  vector<map<long long, long long>> dat;
  map<long long, long long> use;
  map<long long, long long> pse;
  for (long long i = (0); i < (n); i++) {
    if (use.find(i) == use.end()) {
      if (use.find(y[i]) == use.end()) {
        use[i] = dat.size();
        use[y[i]] = dat.size();
        map<long long, long long> tmp;
        tmp[i] = 0;
        tmp[y[i]] = 1;
        dat.push_back(tmp);
      } else {
        auto it = use.find(y[i]);
        it--;
        pse[i] = (*it).first;
      }
    } else {
      use[y[i]] = use[i];
      dat[use[i]][y[i]] = dat[use[i]][i] + 1;
    }
  }
  for (long long i = (0); i < (q); i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      long long tmp = a;
      a = b;
      b = tmp;
    }
    if (pse.find(a) != pse.end()) {
      a = pse[a];
    }
    cout << ((*(dat[use[a]].lower_bound(b))).second - dat[use[a]][a]) << endl;
  }
  return 0;
}
