#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, l, q, cnt = 1, dp[N][35], x[N], pw[35] = {1}, ans;
template <typename I>
inline void read(I &ot) {
  I ch = getchar(), x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  ot = x * f;
}
template <typename I, typename... U>
inline void read(I &x, U &...y) {
  read(x);
  read(y...);
}
template <typename I>
inline void swp(I &a, I &b) {
  I t = a;
  a = b;
  b = t;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(x[i]);
  read(l, q);
  for (int i = 1; i <= n; i++) {
    while (x[i] + l >= x[cnt]) cnt++;
    if (cnt - 1 > n) continue;
    dp[i][0] = cnt - 1;
  }
  for (int i = 1; i <= 20; i++) {
    pw[i] = pw[i - 1] << 1;
    for (int j = 1; j <= n; j++) {
      if (dp[j][i - 1]) dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
  for (int i = 1, a, b; i <= q; i++) {
    read(a, b);
    if (a > b) swp(a, b);
    ans = 0;
    for (int j = 20; j >= 0; j--)
      if (dp[a][j] && dp[a][j] <= b) a = dp[a][j], ans += pw[j];
    printf("%d\n", ans);
  }
  return 0;
}
