#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int n, a[N << 1], Q, f[21][N], L;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &L);
  for (int i = 1; i <= n; i++) {
    int x = upper_bound(a + 1, a + n + 1, a[i] + L) - a - 1;
    f[0][i] = x;
  }
  for (int j = 1; j <= log2(n); j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++) f[j][i] = f[j - 1][f[j - 1][i]];
  scanf("%d", &Q);
  while (Q--) {
    int l, r, ans = 0;
    scanf("%d%d", &l, &r);
    if (l > r) swap(l, r);
    for (long long i = log2(n); i >= 0; i--) {
      if (f[i][l] <= r) l = f[i][l], ans += (1 << i);
    }
    printf("%d\n", ans);
  }
  return 0;
}
