#include <bits/stdc++.h>
using namespace std;
inline long long rf() {
  long long r;
  long long s = 0, c;
  for (; !isdigit(c = getchar()); s = c)
    ;
  for (r = c ^ 48; isdigit(c = getchar()); (r *= 10) += c ^ 48)
    ;
  return s ^ 45 ? r : -r;
}
long long N, L, Q, a[100001], c[100001] = {};
int main() {
  N = rf();
  for (int i = 1; i <= N; i++) a[i] = rf();
  L = rf();
  int r = N, now = 2;
  for (int i = N; i; i--)
    if (a[i] <= a[1] + L) {
      c[1] = i;
      r = i;
      break;
    }
  while (now <= N) {
    while (a[r] <= a[now] + L && r <= N) r++;
    r > N ? r = N : r--;
    c[now] = r;
    now++;
  }
  Q = rf();
  while (Q--) {
    long long aa = rf(), bb = rf(), ans = 0;
    if (aa > bb) swap(aa, bb);
    while (aa <= bb && aa < N) {
      aa = c[aa], ans++;
    }
    ans--;
    printf("%lld\n", ans);
  }
  return 0;
}
