#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool smin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const long long N = 1e5 + 10, lg = 20;
long long n, ar[N], L, dp[N][lg];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> ar[i];
  cin >> L;
  long long can = 1;
  for (long long i = 1; i <= n; ++i) {
    while (can + 1 <= n && ar[can + 1] - ar[i] <= L) ++can;
    dp[i][0] = can;
  }
  for (long long j = 1; j < lg; ++j) {
    for (long long i = 1; i <= n; ++i) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long res = 0;
    for (long long j = lg - 1; ~j; --j) {
      if (dp[a][j] <= b) {
        res += (1 << j);
        a = dp[a][j];
      }
    }
    cout << res << '\n';
  }
}
