#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int N, L, f[maxn][32], t, Q;
long long x[maxn];
inline long long read() {
  long long s = 0, f = 1;
  char ch;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    s = (s << 3) + (s << 1) + ch - '0';
  return s * f;
}
void Work_preparing() {
  memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= N; ++i) {
    int pos = upper_bound(x + i + 1, x + N + 1, 1LL * (x[i] + L)) - x - 1;
    f[i][0] = pos;
  }
  for (int j = 1; j <= t - 1; ++j) {
    for (int i = 1; i <= (N - (1 << j) + 1); ++i)
      f[i][j] = f[f[i][j - 1]][j - 1];
  }
}
long long solve(int l, int r) {
  long long ans = 0;
  for (int i = t - 1; i >= 0; --i) {
    if (f[l][i] <= r) {
      if (f[l][i] == r) {
        ans += (long long)(1 << i);
        break;
      } else {
        ans += (long long)(1 << i) + 1;
        break;
      }
    }
  }
  return ans;
}
void Input() {
  N = read();
  t = (int)(log(N) / log(2)) + 1;
  for (int i = 1; i <= N; ++i) x[i] = read();
  L = read();
  Work_preparing();
  Q = read();
  while (Q--) {
    int a, b;
    a = read(), b = read();
    if (a > b) {
      a ^= b, b ^= a, a ^= b;
    };
    printf("%lld\n", solve(a, b));
  }
}
int main() {
  Input();
  return 0;
}
