#include <bits/stdc++.h>
using namespace std;
int n, x[100010], l, q, a, b, dp[100010][20];
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  scanf("%d", &l);
  for (int i = n - 1; i >= 0; i--) {
    int L = i, R = n;
    while (L + 1 < R) {
      int M = (L + R) / 2;
      if (x[M] - x[i] > l)
        R = M;
      else
        L = M;
    }
    dp[i][0] = L;
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 0; i < n; i++) {
      if (dp[i][j - 1] != -1) dp[i][j] = dp[dp[i][j - 1]][j - 1];
      cout << dp[i][j] << ' ' << i << ' ' << j << '\n';
    }
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &a, &b);
    int ans = 0;
    if (a > b) swap(a, b);
    a--, b--;
    for (int i = 19; i >= 0; i--) {
      if (dp[a][i] != -1 && x[dp[a][i]] < x[b]) ans += (1 << i), a = dp[a][i];
    }
    printf("%d\n", ans + 1);
  }
}
