#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N;
int X[MAXN];
int L, Q;
int dp[MAXN];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &X[i]);
  }
  scanf("%d", &L);
  for (int i = 1, j = 0; i <= N; i++) {
    while (X[i] - X[j] > L) j++;
    dp[i] = dp[j] + 1;
  }
  scanf("%d", &Q);
  while (Q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    printf("%d\n", dp[b] - dp[a - 1]);
  }
}
