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