#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = long long(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr long long LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
int dp[MAX_N][21];
int main() {
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  for (int i = 0; i < N; i++) {
    dp[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  for (int j = 0; j < 20; j++) {
    for (int i = 0; i < N; i++) {
      dp[i][j + 1] = dp[dp[i][j]][j];
    }
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int now = a, cnt = 0;
    while (now != b) {
      for (int j = 20; j >= 0; j--) {
        if (dp[now][j] <= b) {
          now = dp[now][j];
          cnt += 1 << j;
          break;
        } else if (j == 0) {
          now = b;
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
