#include <bits/stdc++.h>
using namespace std;
int n, q, l, a, b, ans, x[100000 + 5], f[100000 + 5][20 + 5];
int read() {
  char c;
  int x = 0, f = 1;
  c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) x[i] = read();
  l = read();
  for (int i = 1; i <= n; ++i) {
    int pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
    if (x[pos] < x[i] + l)
      f[i][0] = n + 1;
    else
      f[i][0] = pos - 1;
  }
  for (int j = 1; j <= 20 + 5 - 5; ++j)
    for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  q = read();
  while (q--) {
    a = read(), b = read(), ans = 0;
    if (a > b) swap(a, b);
    for (int i = 20 + 5 - 5; i >= 0; --i)
      if (f[a][i] < b && f[a][i]) a = f[a][i], ans += (1 << i);
    if (a < b) ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
