#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7, LG = 20;
long long r[LG][N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long L;
  cin >> L;
  long long ptr = 0;
  r[0][n] = n;
  for (long long i = 0; i < n; ++i) {
    while (ptr + 1 < n && a[ptr + 1] <= a[i] + L) ptr++;
    if (ptr == i)
      r[0][i] = n;
    else
      r[0][i] = ptr;
  }
  for (long long i = 1; i < LG; ++i)
    for (long long j = 0; j <= n; ++j) r[i][j] = r[i - 1][r[i - 1][j]];
  long long q;
  cin >> q;
  while (q--) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    if (v < u) swap(u, v);
    long long ans = 0;
    for (long long i = LG - 1; i >= 0; --i) {
      if (r[i][u] <= v) {
        ans += 1 << i;
        u = r[i][u];
      }
    }
    cout << ans << '\n';
  }
}
