#include <bits/stdc++.h>
using namespace std;
const long long SIZE = 1e3 + 100, INF = 1e9 * 1e4 + 10, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, a, b, c, d, dp[SIZE], l, q;
vector<long long> vec;
map<long long, long long> ch;
void sol() {
  cin >> n;
  vec.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  cin >> l;
  vector<pair<long long, long long>> nw;
  for (int i = 0; i < vec.size(); i++) {
    if (nw.size() >= 2) {
      if (nw[nw.size() - 2].first + l >= vec[i]) nw.pop_back();
    }
    nw.push_back({vec[i], i});
  }
  cin >> q;
  for (int i = 0; i < nw.size(); i++) {
    ch[nw[i].second] = i;
  }
  long long pr = -1;
  for (int i = 0; i < vec.size(); i++) {
    if (ch.find(i) == ch.end()) {
      ch[i] = pr;
    } else {
      pr = ch[i];
    }
  }
  while (q--) {
    long long l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    l--;
    r--;
    cout << ch[r] - ch[l] << "\n";
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  long long t = 1;
  while (t--) {
    sol();
  }
  return 0;
}
