#include <bits/stdc++.h>
using namespace std;
int dbl[114514][19];
int x[114514];
int main() {
  int n, l, q, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  scanf("%d", &l);
  int now = 0;
  for (int i = 0; i < n; i++) {
    while (now < n - 1 && x[now + 1] <= x[i] + l) now++;
    dbl[i][0] = now;
  }
  dbl[n - 1][0] = dbl[n][0] = n;
  for (int i = 0; i < 19; i++) dbl[n][i] = n;
  for (int i = 0; i < 18; i++)
    for (int j = 0; j < n; j++) dbl[j][i + 1] = dbl[dbl[j][i]][i];
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &a, &b);
    if (a > b) swap(a, b);
    a--;
    b--;
    int ret = 0;
    for (int i = 18; i >= 0; i--) {
      if (dbl[a][i] <= b) a = dbl[a][i], ret += (1 << i);
    }
    printf("%d\n", ret);
  }
}
