#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  for (; !isalnum(ch); ch = getchar())
    ;
  for (; isalnum(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x;
}
const int xx = 1e5 + 1612;
int to[xx][18];
int x[xx], n, L;
inline void init() {
  n = read();
  for (register int i = 1; i <= n; ++i) x[i] = read();
  L = read();
  int j = n;
  to[n][0] = j;
  for (register int i = n - 1; i >= 1; --i) {
    while (x[j] - x[i] > L) --j;
    to[i][0] = j;
  }
  for (register int k = 1; k <= log(n) / log(2) + 1; ++k)
    for (register int i = 1; i <= n; ++i) to[i][k] = to[to[i][k - 1]][k - 1];
}
inline int power(int b, int k) {
  int res = 1;
  for (; k; k >>= 1, b = b * b)
    if (k & 1) res = res * b;
  return res;
}
inline void sol(int a, int b) {
  if (a > b) swap(a, b);
  int j = a, g = log(n) / log(2) + 1;
  int ans = 0;
  while (j < b) {
    while (to[j][g] > b && g) --g;
    j = to[j][g];
    ans += power(2, g);
  }
  printf("%d\n", ans);
}
signed main() {
  init();
  int T = read();
  while (T--) sol(read(), read());
  return 0;
}
