#include <bits/stdc++.h>
const int MAXN = 1E5 + 5;
const int LOGN = 18;
int array[MAXN]{};
int dp[MAXN]{};
int spars[LOGN][MAXN]{};
int A, B, D, N, Q;
void solve() {
  dp[1] = 0;
  int head = 1, tail = 1;
  while (head <= N) {
    if (tail < head) tail = head;
    bool end = (array[tail] - array[head] > D);
    spars[0][head] = tail - end;
    while ((tail <= N) && (array[tail] - array[head] <= D)) {
      dp[tail] = std::min(dp[head] + 1, dp[tail]);
      spars[0][head] = tail;
      ++tail;
    }
    ++head;
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &array[i]);
    dp[i] = MAXN;
  }
  scanf(" %d%d", &D, &Q);
  array[N + 1] = array[N] + D + 1;
  solve();
  for (int day = 1; day < LOGN; ++day)
    for (int hot = 1; hot <= N; ++hot)
      spars[day][hot] = spars[day - 1][spars[day - 1][hot]];
  while (Q-- > 0) {
    scanf(" %d%d", &A, &B);
    if (A > B) std::swap(A, B);
    int cnt, K = B - A, ret = 0;
    do {
      cnt = 0;
      while ((cnt < LOGN) && (spars[cnt + 1][A] <= B)) ++cnt;
      if (cnt || spars[cnt][A] <= B) ret += 1 << cnt;
      A = spars[cnt][A];
    } while (cnt);
    printf("%d\n", ret);
  }
  return 0;
}
