#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7, LG = 20;
long long a[N];
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;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long L;
  cin >> L;
  r[0][n - 1] = r[0][n] = n;
  long long ptr = 0;
  for (long long i = 0; i + 1 < n; ++i) {
    while (ptr + 1 < n && a[ptr + 1] <= a[i] + L) {
      ptr++;
    }
    assert(ptr > i);
    r[0][i] = ptr;
  }
  for (long long p = 1; p < LG; ++p)
    for (long long i = 0; i <= n; ++i) r[p][i] = r[p - 1][r[p - 1][i]];
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (b < a) swap(a, b);
    long long ans = 0;
    for (long long p = LG - 1; p >= 0; --p) {
      if (r[p][a] <= b) {
        a = r[p][a];
        ans += 1 << p;
      }
    }
    cout << ans << '\n';
  }
}
