#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, l;
int site[100005];
int fw[100005], bw[100005];
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &site[i]);
  scanf("%d", &l);
  sort(site, site + n + 1);
  fw[0] = 1;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = fw[i - 1] + 1;; j++) {
      if (site[j] - site[i] > l) {
        fw[i] = j - 1;
        break;
      }
      if (j == n) {
        fw[i] = n;
        break;
      }
    }
  }
  fw[n] = n;
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int t = a;
    int cnt = 0;
    while (t < b) {
      t = fw[t];
      cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
