#include <bits/stdc++.h>
const int MAXN = 1E5 + 5;
int array[MAXN]{};
int dp[MAXN]{};
int A, B, L, N, Q;
int solve() {
  memset((dp), (0x63), sizeof(dp));
  if (A > B) std::swap(A, B);
  dp[A] = 0;
  int head = A, tail = A + 1;
  while (tail <= B) {
    if (tail <= head) tail = head + 1;
    while ((tail <= N) && (array[tail] - array[head] <= L)) {
      dp[tail] = std::min(dp[head] + 1, dp[tail]);
      ++tail;
    }
    ++head;
  }
  return dp[B];
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &array[i]);
  scanf(" %d%d", &L, &Q);
  while (Q-- > 0) {
    scanf(" %d%d", &A, &B);
    printf("%d\n", solve());
  }
  return 0;
}
