#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int s[maxn], n, L, Q;
int cnt[maxn];
int main() {
  s[0] = 0;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
    scanf("%d", &L);
    for (int i = 1; i <= n; i++) {
      int tmp = i + 1;
      while (s[tmp] - s[i] <= L && tmp <= n) tmp++;
      cnt[i] = tmp - 1;
    }
    scanf("%d", &Q);
    while (Q--) {
      int a, b, ans = 0;
      scanf("%d%d", &a, &b);
      if (a > b) swap(a, b);
      int tmp = a, sum = 0;
      while (cnt[a] <= b) {
        a = cnt[a];
        ans++;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
