#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  vector<long long> X(N);
  vector<long long> oneday(N);
  for (auto&& x : X) {
    cin >> x;
  }
  long long L;
  cin >> L;
  long long l = 0, r = 1;
  while (r < N) {
    if (X[r] - X[l] > L) {
      oneday[l] = r - 1;
      l++;
    } else {
      r++;
    }
  }
  for (; l < r; l++) {
    oneday[l] = r;
  }
  long long Q;
  cin >> Q;
  vector<pair<long long, long long> > queries;
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a <= b) {
      queries.push_back(pair<long long, long long>(a - 1, b - 1));
    } else {
      queries.push_back(pair<long long, long long>(b - 1, a - 1));
    }
  }
  for (auto&& q : queries) {
    long long day = 1;
    for (long long cur = q.first; oneday[cur] < q.second;
         cur = oneday[cur], day++)
      ;
    cout << day << endl;
  }
  return 0;
}
