#include <bits/stdc++.h>
using namespace std;
int n, m, k, cnt, L, R, now, last;
int a[100005];
int dp[100005];
int main() {
  int i, j, x, y;
  scanf("%d", &n);
  now = last = 1;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &k);
  for (i = 2; i <= n; ++i) {
    if (a[i] - k <= a[now])
      dp[i] = dp[now] + 1;
    else {
      dp[i] = dp[last] + 1;
      now = last;
    }
    last = i;
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x == y) {
      printf("0\n");
      continue;
    }
    if (x > y) swap(x, y);
    int ans = dp[y] - dp[x];
    printf("%d\n", ans + (ans == 0 ? 1 : 0));
  }
  return 0;
}
