#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, L, Q;
  cin >> N;
  vector<int64_t> x(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  cin >> L >> Q;
  vector<vector<int64_t>> next(N, vector<int64_t>(N));
  for (int i = 0; i < N; ++i) {
    next[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  for (int i = 1; i < log2(N); ++i) {
    for (int j = 0; j < N; ++j) {
      next[i][j] = next[i - 1][next[i - 1][j]];
    }
  }
  for (int t = 0; t < Q; ++t) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) swap(a, b);
    int now = a;
    int ans = 1;
    for (int i = log2(N) - 1; i >= 0; --i) {
      if (next[i][now] < b) {
        now = next[i][now];
        ans += 1 << i;
      }
    }
    cout << ans << endl;
  }
}
