#include <bits/stdc++.h>
int main() {
  int n, m, q, a, b, temp, ans, d, last, x[100005][2] = {};
  scanf("%d", &n);
  last = n;
  for (int i = 1; i <= n; i++) scanf("%d", &x[i][0]);
  scanf("%d %d", &m, &q);
  for (int i = n; x[1][1] == 0; i--) {
    d = x[i][0] - m;
    if (x[last][0] < d) continue;
    for (int j = last; j >= 1 && x[j][0] >= d; j--, last--) x[j][1] = i;
  }
  while (q > 0) {
    q--;
    scanf("%d %d", &a, &b);
    ans = 0;
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
    }
    while (x[a][1] < b) {
      a = x[a][1];
      ans++;
    }
    printf("%d\n", ans + 1);
  }
  system("pause");
  return 0;
}
