#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  ll to, cap, rev;
  Edge(ll _to, ll _cap, ll _rev) {
    to = _to;
    cap = _cap;
    rev = _rev;
  }
};
void add_edge(vector<vector<Edge>> &G, ll from, ll to, ll cap, bool revFlag,
              ll revCap) {
  G[from].push_back(Edge(to, cap, (ll)G[to].size()));
  if (revFlag) G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve() {
  ll n;
  cin >> n;
  vec<ll> x(n);
  for (int(i) = (int)(0); i < (int)(n); ++i) {
    cin >> x[i];
  }
  ll l;
  cin >> l;
  vvec<ll> next(20, vec<ll>(n, 0));
  for (int(i) = (int)(0); i < (int)(n); ++i) {
    auto it = upper_bound((x).begin(), (x).end(), x[i] + l);
    it--;
    next[0][i] = it - x.begin();
  }
  for (int(i) = (int)(0); i < (int)(19); ++i) {
    for (int(j) = (int)(0); j < (int)(n); ++j) {
      next[i + 1][j] = next[i][next[i][j]];
    }
  }
  ll q;
  cin >> q;
  while (q--) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    ll ans = n;
    ll con = 0;
    int now = a;
    for (int(i) = (int)(20) - 1; i >= (int)(0); --i) {
      if (next[i][now] == b) {
        con += 1LL << i;
        chmin(ans, con);
        break;
      } else if (next[i][now] < b) {
        con += 1LL << i;
        now = next[i][now];
      } else {
        chmin(ans, con + (1LL << i));
      }
    }
    cout << ans << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
