#include <bits/stdc++.h>
using namespace std;
long long dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
long long dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long N, L, Q;
long long x[110000], a[110000], b[110000];
long long dp[110000][20];
signed main() {
  cin >> N;
  for (long long i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (long long i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < 18; j++) {
      dp[i][j] = 110000;
    }
  }
  for (long long i = 0; i < N; i++) {
    dp[i][0] = upper_bound(x, x + N, x[i] + L) - x - 1;
  }
  for (long long i = 0; i < 18; i++) {
    for (long long j = 0; j < N; j++) {
      dp[j][i + 1] = dp[dp[j][i]][i];
    }
  }
  for (long long i = 0; i < Q; i++) {
    if (a[i] > b[i]) swap(a[i], b[i]);
    a[i]--;
    b[i]--;
    long long ans = 0;
    while (a[i] != b[i]) {
      long long lb = -1, ub = 16;
      while (ub - lb > 1) {
        long long mid = (lb + ub) / 2;
        if (dp[a[i]][mid] > b[i]) {
          ub = mid;
        } else {
          lb = mid;
        }
      }
      ans += 1 << (ub - 1);
      a[i] = dp[a[i]][ub - 1];
    }
    cout << ans << endl;
  }
  return 0;
}
