#include <bits/stdc++.h>
using namespace std;
long long hotel[100000];
long long last[100000];
queue<pair<long long, long long> > q;
signed main() {
  long long n, l;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> hotel[i];
  }
  cin >> l;
  for (long long i = 0; i < n; i++) {
    q.push(pair<long long, long long>(hotel[i], i));
    while (q.back().first > q.front().first + l) {
      last[q.front().second] = q.back().second - 1;
      q.pop();
    }
  }
  while (!q.empty()) {
    last[q.front().second] = q.back().second;
    q.pop();
  }
  long long q, a, b;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    a--;
    b--;
    long long coun = 0;
    while (a < b) {
      a = last[a];
      coun++;
    }
    cout << coun << "\n";
  }
}
