#include <bits/stdc++.h>
int const K = 20;
int const N = 1234567;
int pp[K][N];
int x[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", x + i);
  }
  int L;
  scanf("%d", &L);
  x[n] = x[n - 1] + L;
  for (int i = 0, j = 0; i < n; i++) {
    while (j + 1 <= n && x[j + 1] - x[i] <= L) {
      ++j;
    }
    pp[0][i] = j;
    assert(i < j);
  }
  pp[0][n] = n;
  for (int i = 1; i < K; i++) {
    for (int v = 0; v <= n; v++) {
      pp[i][v] = pp[i - 1][pp[i - 1][v]];
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int left, right;
    scanf("%d%d", &left, &right);
    --left;
    --right;
    if (left > right) std::swap(left, right);
    int ans = 0;
    for (int j = K - 1; j >= 0; j--) {
      if (pp[j][left] <= right) {
        left = pp[j][left];
        ans += 1 << j;
      }
    }
    assert(left == right);
    printf("%d\n", ans);
  }
}
