#include <bits/stdc++.h>
long long arr[100005];
int dis[100005];
long long l;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  scanf("%lld", &l);
  arr[1] = 0;
  int now = 1;
  int i = 1;
  while (true) {
    int j;
    for (j = i + 1; j <= n; j++) {
      if (arr[j] - arr[i] <= l) {
        dis[j] = now;
      } else {
        now++;
        break;
      }
    }
    if (j >= n) break;
    i = j - 1;
  }
  for (int i = 1; i <= n; i++) {
  }
  int Q;
  scanf("%d", &Q);
  int s, t;
  for (int i = 0; i < Q; i++) {
    scanf("%d%d", &s, &t);
    if (s > t) {
      int temp = s;
      s = t;
      t = temp;
    }
    if (dis[t] - dis[s]) {
      printf("%d\n", dis[t] - dis[s]);
    } else {
      printf("1\n");
    }
  }
}
