#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
template <typename T>
void fin(T a) {
  cout << a << endl;
  exit(0);
}
long long pw(long long n, long long k) {
  if (k < 0) return pw(n, k + MOD - 1);
  long long res = 1;
  while (k) {
    if (k & 1) res *= n;
    n *= n;
    k >>= 1;
  }
  return res;
}
long long d[123456][35];
signed main() {
  long long N, L, Q;
  cin >> N;
  std::vector<long long> v(N);
  for (long long i = 0; i < N; i++) cin >> v[i];
  cin >> L >> Q;
  std::vector<long long> a(Q), b(Q);
  for (long long i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  for (long long i = 0; i < N; i++) {
    long long l = i + 1, r = N;
    while (r - l > 1) {
      long long m = (r + l) >> 1;
      if (v[m] <= v[i] + L)
        l = m;
      else
        r = m;
    }
    d[i][0] = l;
  }
  for (long long j = 0; j < 35; j++) d[N][j] = N;
  for (long long j = 1; j < 35; j++)
    for (long long i = 0; i < N; i++) d[i][j] = d[d[i][j - 1]][j - 1];
  for (long long i = 0; i < Q; i++) {
    long long ans = 0;
    long long s = a[i], g = b[i];
    for (long long j = 34; j >= 0; j--) {
      if (d[s][j] <= g) {
        ans += pw(2, j);
        s = d[s][j];
      }
    }
    cout << ans << endl;
  }
}
