#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
inline long long ni() {
  long long x;
  cin >> x;
  return x;
}
template <class T>
inline T nt() {
  T x;
  cin >> x;
  return x;
}
inline void print() {}
template <typename T, typename... TAIL>
inline void print(const T &t, TAIL... tail) {
  cout << t;
  print(tail...);
}
inline void input() { return; }
template <typename T, typename... TAIL>
inline void input(T &t, TAIL &...tail) {
  cin >> t;
  input(tail...);
}
const long long N = 2 * 1005001;
const long long inf = 1e9 + 7;
const double PI = 3.14159265359;
vector<long long> v;
long long L;
long long go[N][20];
signed main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  long long n = ni();
  for (long long i = 0; i < n; i++) v.push_back(ni());
  L = ni();
  for (long long i = 0; i < n; i++) {
    long long l = i + 1, r = n;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (v[m] - v[i] <= L)
        l = m;
      else
        r = m;
    }
    go[i][0] = l;
  }
  go[n][0] = n;
  for (long long j = 1; j < 20; j++) {
    for (long long i = 0; i <= n; i++) {
      go[i][j] = go[go[i][j - 1]][j - 1];
    }
  }
  long long Q = ni();
  for (long long i = 0; i < Q; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    if (l > r) swap(l, r);
    long long ans = 0;
    for (long long i = 19; i >= 0; i--) {
      if (go[l][i] <= r) {
        l = go[l][i];
        ans += 1 << i;
      }
    }
    cout << ans << '\n';
  }
}
