#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<ll> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  ll L;
  cin >> L;
  vector<vector<int>> nxt(100, vector<int>(N));
  int j = 0;
  for (int i = 0; i < N; i++) {
    while (j + 1 < N && x[j + 1] - x[i] <= L) {
      ++j;
    }
    nxt[0][i] = j;
  }
  for (int k = 1; k < 100; k++) {
    for (int i = 0; i < N; i++) {
      nxt[k][i] = nxt[k - 1][nxt[k - 1][i]];
    }
  }
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    ll res = 0;
    for (int k = 99; k >= 0; k--) {
      int a2 = nxt[k][a];
      if (a2 <= b) {
        a = a2;
        res += 1ll << k;
      }
    }
    if (a != b) {
      ++res;
    }
    cout << res << endl;
  }
  return 0;
}
