#include <bits/stdc++.h>
using namespace std;
long long int n, l, q, dp[100005];
long long int A[100005];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &A[i]);
  scanf("%lld", &l);
  dp[0] = dp[1] = 0;
  long long int nw = 1, say = 1;
  for (int i = 2; i <= n; i++) {
    if (A[i] - A[nw] <= l) {
      dp[i] = say;
    } else {
      nw = i - 1;
      dp[i] = ++say;
    }
  }
  scanf("%lld", &q);
  for (int i = 1; i <= q; i++) {
    long long int x, y;
    scanf("%lld %lld", &x, &y);
    if (x < y) swap(x, y);
    printf("%lld\n", dp[x] - dp[y - 1]);
  }
  return 0;
}
