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