#include <bits/stdc++.h>
using namespace std;
const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e5 + 10;
int n, m;
int a[MAXN];
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &m);
}
int fa[MAXN][20];
void solve() {
  a[n + 1] = 2e9 + 10;
  for (int i = 1; i <= n; i++) {
    fa[i][0] = lower_bound(a + 1, a + n + 2, a[i] + m + 1) - a - 1;
  }
  int cnt = 0;
  for (int j = 0, k = 1; k <= n; j++, k *= 2) {
    for (int i = 1; i <= n; i++) fa[i][j + 1] = fa[fa[i][j]][j];
    cnt++;
  }
  int Q;
  scanf("%d", &Q);
  for (int o = 1; o <= Q; o++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    int ans = 0;
    for (int i = cnt; i; i--) {
      if (fa[x][i] < y) {
        ans += (1 << i);
        x = fa[x][i];
      }
    }
    while (x != y) {
      ans++;
      x = fa[x][0];
    }
    printf("%d\n", ans);
  }
}
void printans() {}
int main() {
  int T = 1;
  while (T--) {
    read();
    solve();
    printans();
  }
  return 0;
}
