#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll << 60);
int main() {
  long long N;
  cin >> N;
  vector<long long> x(N);
  for (long long i = 0; i < N; i++) {
    cin >> x[i];
  }
  long long L;
  cin >> L;
  vector<vector<long long> > dp(N, vector<long long>(20, -1));
  for (long long i = 0; i < N; i++) {
    dp[i][0] =
        distance(x.begin(), upper_bound(x.begin(), x.end(), x[i] + L)) - 1;
  }
  for (long long i = 1; i < 20; i++) {
    for (long long j = N - 1; j >= 0; j--) {
      dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
  long long Q;
  cin >> Q;
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long cnt = 0;
    while (true) {
      long long j =
          distance(dp[a].begin(), lower_bound(dp[a].begin(), dp[a].end(), b));
      if (j == 0) {
        cnt += 1;
        break;
      }
      a = dp[a][j - 1];
      cnt += 1ll << (j - 1);
    }
    cout << cnt << endl;
  }
}
