#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
const long double pi = acos(-1.0);
int n, a[100100], to[100100][20], len, q;
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 * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  len = read();
  for (register int i = 1; i <= n; i++) {
    int pos = upper_bound(a + 1, a + 1 + n, a[i] + len) - a - 1;
    if (pos <= n) to[i][0] = pos;
  }
  for (register int j = 1; j <= 19; j++)
    for (register int i = 1; i <= n; i++) to[i][j] = to[to[i][j - 1]][j - 1];
  q = read();
  while (q--) {
    int u = read(), v = read();
    if (u > v) swap(u, v);
    int ans = 0;
    for (register int i = 19; i >= 0; i--)
      if (to[u][i] <= v) {
        u = to[u][i];
        ans += (1 << i);
      }
    printf("%d\n", ans);
  }
  return 0;
}
