#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> m;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, l, q;
  cin >> n;
  vector<int> val(n + 1);
  vector<bool> d(n + 1, 0);
  vector<vector<int> > a;
  for (int i = 1; i < n + 1; ++i) cin >> val[i];
  cin >> l >> q;
  int ind = -1;
  for (int i = 1; i < n + 1; ++i) {
    if (d[i] == 0) {
      d[i] = 1;
      a.emplace_back();
      a.back().emplace_back(val[i]);
      int j = i;
      ++ind;
      m[j] = ind;
      int maxn = val[i] + l;
      int v = upper_bound(val.begin(), val.end(), maxn) - val.begin() - 1;
      while (v != j && val[v] <= maxn) {
        a.back().emplace_back(val[v]);
        j = v;
        d[j] = 1;
        m[j] = ind;
        maxn = val[j] + l;
        v = upper_bound(val.begin(), val.end(), maxn) - val.begin() - 1;
      }
    }
  }
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    ind = m[x];
    x = lower_bound(a[ind].begin(), a[ind].end(), val[x]) - a[ind].begin();
    y = upper_bound(a[ind].begin(), a[ind].end(), val[y]) - a[ind].begin();
    cout << y - x - 1 << '\n';
  }
}
