#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, x[maxn], l, q, a, b, beizen[maxn][21];
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) x[i] = read();
  l = read(), q = read();
  while (q--) {
    a = read(), b = read();
    if (a > b) swap(a, b);
    int ans = 0;
    while (x[a] < x[b] && a < b) {
      int bushu = upper_bound(x + 1, x + n + 1, x[a] + l) - x - 1 - a;
      ans++;
      a += bushu;
    }
    printf("%d\n", ans);
  }
}
