#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
const int LOGV = 17;
int dp[LOGV][MAXN], X[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, L, Q, logV;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> X[i];
  }
  for (logV = 1; (1 << (logV + 1)) <= N; logV++)
    ;
  cin >> L;
  for (int i = 1, j = 1; i <= N; i++) {
    while (j <= N && X[j] - X[i] <= L) j++;
    dp[0][i] = j - 1;
  }
  for (int i = 1; i <= logV; i++) {
    for (int j = 1; j + (i << i) - 1 <= N; j++) {
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
  }
  cin >> Q;
  int a, b;
  while (Q--) {
    cin >> a >> b;
    if (a > b) a ^= b ^= a ^= b;
    int step = 0;
    for (int i = logV; i >= 0; i--) {
      if (dp[i][a] && dp[i][a] < b) {
        step += 1 << i;
        a = dp[i][a];
      }
    }
    cout << step + 1 << endl;
  }
  return 0;
}
