#include <bits/stdc++.h>
int a[100010], b[100010], x[100010], r[100010][20];
int *binary(int *seq, const int len, const int key) {
  int left, mid, right;
  left = 0;
  right = len - 1;
  mid = (left + right) / 2;
  while (left <= right) {
    if (*(seq + mid) < key)
      left = mid + 1;
    else if (*(seq + mid) > key)
      right = mid - 1;
    else
      break;
    mid = (left + right) / 2;
  }
  return seq + mid;
}
int main() {
  int D, from, i, j, k, L, N, *ptr, Q, to;
  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &x[i]);
  scanf("%d%d", &L, &Q);
  for (j = 0; j < Q; j++) scanf("%d%d", &a[j], &b[j]);
  for (i = 0; i < N - 1; i++) {
    ptr = binary(x, N, x[i] + L);
    r[i][0] = ptr - x + 1;
  }
  r[N - 1][0] = N;
  for (k = 1; k < 20; k++) {
    for (i = 0; i < N - 1; i++) {
      r[i][k] = r[r[i][k - 1] - 1][k - 1];
    }
    r[N - 1][k] = N;
  }
  for (j = 0; j < Q; j++) {
    D = 0;
    if (a[j] > b[j]) {
      from = b[j];
      to = a[j];
    } else {
      from = a[j];
      to = b[j];
    }
    do {
      ptr = binary(r[from - 1], 20, to);
      i = ptr - r[from - 1];
      k = 1;
      while (i-- > 0) k *= 2;
      D += k;
      from = *ptr;
    } while (*ptr < to);
    printf("%d\n", D);
  }
  return 0;
}
