#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, last;
  int N, Q, L;
  int x[100001];
  int b[100001];
  int c, d;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &L);
  i = 1;
  j = 1;
  for (; i <= N;) {
    for (; j <= N;) {
      if ((x[j] - x[i] <= L)) {
        last = j;
        j++;
      } else {
        b[i] = last;
        i++;
      }
    }
    if (last == N) {
      b[i] = last;
      i++;
    }
  }
  scanf("%d", &Q);
  for (i = 1; i <= Q; i++) {
    scanf("%d", &c);
    scanf("%d", &d);
    if (c > d) {
      j = c;
      c = d;
      d = j;
    }
    j = 1;
    while (b[c] < d) {
      c = b[c];
      j++;
    }
    printf("%d\n", j);
  }
  return 0;
}
