#include <bits/stdc++.h>
using namespace std;
int n, l, q, h[100010], a, b;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", h + i);
  scanf("%d%d", &l, &q);
  while (q--) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int cnt = 0, now = a;
    while (now < b) {
      now = (int)(upper_bound(h + 1, h + n + 1, h[now] + l) - h) - 1;
      cnt++;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
