#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long u = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    u = (u << 1) + (u << 3) + ch - 48;
    ch = getchar();
  }
  return u * f;
}
const long long maxn = 2e5 + 10;
long long n, L, Q;
long long x[maxn], go[maxn][20];
inline void Pre() {
  long long ipos = 1;
  for (long long i = 1; i <= n; ++i) {
    while (ipos <= n && x[ipos] - x[i] <= L) ipos++;
    go[i][0] = ipos - 1;
  }
  for (long long i = 1; i < 20; ++i) {
    for (long long j = 1; j <= n; ++j) go[j][i] = go[go[j][i - 1]][i - 1];
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j < 20; ++j)
      if (go[i][j - 1] >= n) go[i][j] = INT_MAX;
  }
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) x[i] = read();
  L = read();
  Pre();
  Q = read();
  while (Q--) {
    long long a = read(), b = read();
    if (a == b) {
      cout << "0\n";
      continue;
    }
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long i = 19; ~i; --i) {
      long long V = go[a][i];
      if (V == 0ll) continue;
      if (V <= b) {
        a = V;
        ans += (1 << i);
      }
    }
    if (x[a] != x[b]) ans++;
    printf("%lld\n", ans);
  }
  return 0;
}
