#include <bits/stdc++.h>
using namespace std;
long long x[100050];
long long nxt[100050][31];
int main() {
  long long n, q, l;
  scanf("%lld", &n);
  for (long long i = 0; i < n; ++i) scanf("%lld", &x[i]);
  scanf("%lld", &l);
  for (long long j = 0; j < 20; ++j) {
    for (long long i = 0; i < n; ++i) {
      if (j == 0) {
        if (i != n - 1)
          nxt[i][j] = upper_bound(x + i, x + n, x[i] + l) - x - 1;
        else
          nxt[i][j] = n + 1;
      } else if (nxt[i][j - 1] < n)
        nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  scanf("%lld", &q);
  while (q--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    --a;
    --b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long i = 30; i >= 0; --i) {
      if (a == b) break;
      if (nxt[a][i] <= b) {
        ans += 1 << i;
        a = nxt[a][i];
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
