#include <bits/stdc++.h>
int n;
int w[100005], next[100005][21];
int ex[21];
int L;
int path(int s, int f) {
  if (s >= f) return 0;
  int i;
  for (i = 20; i >= 0; i--) {
    if (next[s][i] == 0) continue;
    if (next[s][i] <= f) {
      return ex[i] + path(next[s][i], f);
      break;
    }
  }
}
int main() {
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) scanf("%d", &w[i]);
  w[n + 1] = 2100000000;
  scanf("%d", &L);
  int nxt = 2;
  for (i = 1; i <= n; i++) {
    while (w[nxt] - w[i] <= L && nxt <= n) nxt++;
    next[i][0] = nxt - 1;
  }
  next[n][0] = 0;
  ex[0] = 1;
  for (i = 1;; i++) {
    ex[i] = ex[i - 1] * 2;
    bool end = true;
    for (j = 1; j < n; j++) {
      if (next[j][i - 1] && next[next[j][i - 1]][i - 1]) {
        next[j][i] = next[next[j][i - 1]][i - 1];
        end = false;
      } else
        break;
    }
    if (end) break;
  }
  int Q;
  scanf("%d", &Q);
  while (Q-- > 0) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) {
      int t = a;
      a = b;
      b = t;
    }
    printf("%d\n", path(a, b));
  }
  return 0;
}
