#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, LOGN = 18, INF = 1e18 + 9;
long long n, q, u, v, dist;
long long a[N], jump[LOGN][N];
void init() {
  for (long long i = 1; i <= LOGN; i++) {
    for (long long j = 1; j <= n; j++) {
      if (jump[i - 1][j] == INF) continue;
      jump[i][j] = jump[i - 1][jump[i - 1][j]];
    }
  }
}
long long solve(long long u, long long v) {
  long long ans = 0;
  for (long long j = LOGN; j >= 0; j--) {
    if (jump[j][u] >= v) continue;
    u = jump[j][u];
    ans += (1 << j);
  }
  if (a[v] - a[u] <= dist) {
    return ans + 1;
  }
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  a[n + 1] = INF;
  for (long long i = 0; i <= LOGN; i++) {
    for (long long j = 1; j <= n; j++) {
      jump[i][j] = INF;
    }
  }
  cin >> dist;
  for (long long i = 1; i <= n; i++) {
    long long l = i;
    for (long long j = 20; j >= 0; j--) {
      long long r = l + (1 << j);
      if (r > n)
        continue;
      else {
        if (a[r] - a[i] <= dist) l += (1 << j);
      }
    }
    jump[0][i] = l;
  }
  jump[0][n] = INF;
  init();
  cin >> q;
  while (q--) {
    cin >> u >> v;
    if (v < u) swap(u, v);
    cout << solve(u, v) << endl;
  }
}
