#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < (N); ++i) cin >> x[i];
  cin >> L >> Q;
  int K = 31 - __builtin_clz(N - 1);
  vector<vector<int>> dp(N, vector<int>(K + 1));
  for (int i = 0; i < (N); ++i) {
    dp[i][0] =
        distance(x.begin(), upper_bound((x).begin(), (x).end(), x[i] + L)) - 1;
  }
  for (int j = (1); j < (K + 1); ++j)
    for (int i = 0; i < (N); ++i) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  for (int _ = 0; _ < (Q); ++_) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) {
      swap(a, b);
    }
    int result = 0;
    for (int i = (K + 1) - 1; i >= 0; --i) {
      if (dp[a][i] < b) {
        a = dp[a][i];
        result += 1 << i;
      }
    }
    ++result;
    cout << result << '\n';
  }
  cout << flush;
  return 0;
}
