#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 11451419198109130;
struct edge {
  long long to, cor;
};
long long x[200005];
vector<long long> V;
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> x[i];
  long long l, q;
  cin >> l >> q;
  long long now = 0;
  for (long long i = 0; i < n; i++) {
    if (x[i] - x[now] > l) {
      V.push_back(now);
      now = i - 1;
    }
  }
  V.push_back(now);
  V.push_back(n - 1);
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    auto posa = lower_bound(V.begin(), V.end(), a);
    long long posb = lower_bound(V.begin(), V.end(), b) - V.begin();
    long long pair<long long, long long> = posa - V.begin();
    if (*posa != a) pair<long long, long long> --;
    cout << posb - pair<long long, long long> << endl;
  }
}
