#include <bits/stdc++.h>
using namespace std;
long long power = 17;
long long move(vector<vector<long long>>& d, long long a, long long b) {
  long long res = 0;
  long long now = a;
  while (now < b) {
    long long temp = 0;
    for (long long i = 0; i < power; ++i) {
      if (d.at(i).at(now) <= b) {
        temp = i;
      } else {
        res += pow(2, temp);
        now = d.at(temp).at(now);
        break;
      }
    }
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N;
  cin >> N;
  vector<long long> X(N + 1, 0);
  for (long long i = 1; i <= N; ++i) {
    cin >> X.at(i);
  }
  long long L;
  cin >> L;
  vector<vector<long long>> d(power, vector<long long>(N + 1));
  d.at(0).at(N) = N;
  for (long long i = 0; i < N; ++i) {
    d.at(0).at(i) = upper_bound(X.begin(), X.end(), min(X.at(i) + L, X.at(N))) -
                    X.begin() - 1;
  }
  for (long long i = 0; i < power - 1; ++i) {
    for (long long j = 0; j <= N; ++j) {
      d.at(i + 1).at(j) = d.at(i).at(d.at(i).at(j));
    }
  }
  long long Q;
  cin >> Q;
  for (long long i = 0; i < Q; ++i) {
    long long a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    cout << move(d, a, b) << "\n";
  }
}
