#include <bits/stdc++.h>
using namespace std;
struct h {
  int num, x;
} a[100005];
int n, f[100005], L;
int q, p[100005];
bool cmp(h x, h y) {
  if (x.x < y.x) return 1;
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].num = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) f[a[i].num] = i;
  scanf("%d", &L);
  for (int i = 1, step = 1; i <= n; i++) {
    while (a[i].x - a[step].x > L) step++;
    p[i] = step;
  }
  scanf("%d", &q);
  int x, y, k, ans;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    ans = 0;
    k = f[y];
    while (k > f[x]) {
      ans++;
      k = p[k];
    }
    printf("%d\n", ans);
  }
  return 0;
}
