#include <bits/stdc++.h>
using namespace std;
int n, in[100005], len, right, x[100005], q, l, r;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &in[i]);
  right = n;
  scanf("%d", &len);
  for (int i = n - 1; i; --i) {
    while (in[right] - in[i] > len) right--;
    x[i] = x[right] + 1;
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &l, &r);
    printf("%d\n", abs(x[l] - x[r]));
  }
  return 0;
}
