#include <bits/stdc++.h>
using namespace std;
int N, L, Q;
int dp[18][200010];
int main() {
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  cin >> L >> Q;
  for (int j = 0; j < N; j++) {
    decltype(X)::iterator it = upper_bound(X.begin(), X.end(), X[j] + L);
    int t = it - X.begin() - 1;
    cout << t << endl;
    dp[0][j] = t;
  }
  for (int i = 1; i <= 18; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  }
  int a, b;
  int beki[20] = {1};
  for (int i = 1; i <= 18; i++) beki[i] = 2 * beki[i - 1];
  for (int i = 0; i < Q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    int l = 0, r = 1e9;
    while (l + 1 < r) {
      int m = (l + r) / 2, res = m;
      int now = a;
      for (int i = 18; i >= 0; i--) {
        if (res <= 0) break;
        if (res >= beki[i]) {
          res -= beki[i];
          now = dp[i][now];
        }
      }
      if (now >= b)
        r = m;
      else
        l = m;
    }
    cout << r << endl;
  }
}
