#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 2;
const int MX = 100004;
int N, M, k;
long long X[MX];
int dp[MX][18];
int get(int u, int D) {
  if (D == 0) return u;
  for (int i = 17; i >= 0; i--) {
    if (D & (1 << i)) u = dp[u][i];
  }
  return u;
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &X[i]);
  scanf("%d", &k);
  for (int i = 2; i <= N; i++) {
    dp[i][0] = lower_bound(X + 1, X + 1 + N, X[i] - k) - X;
    for (int j = 1; j <= 17; j++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int lo = 0, hi = b - a, R = 0, mid;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      int res = get(b, mid);
      if (res <= a) {
        R = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    cout << R << "\n";
  }
  return 0;
}
