#include <bits/stdc++.h>
using ll = long long;
using P = std::pair<ll, ll>;
const ll MOD = 1e9 + 7;
ll max[20][100010];
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  ll n, l, q;
  std::cin >> n;
  std::vector<ll> x(n);
  for (ll(i) = (0); i < (n); i++) std::cin >> x[i];
  std::cin >> l >> q;
  for (ll(i) = (0); i < (n); i++)
    max[0][i] =
        (ll)(std::upper_bound(x.begin(), x.end(), x[i] + l) - x.begin()) - 1;
  for (ll(k) = (1); k < (20); k++) {
    for (ll(i) = (0); i < (n); i++) {
      max[k][i] = max[k - 1][max[k - 1][i]];
    }
  }
  for (ll(sdf) = (0); sdf < (q); sdf++) {
    ll a, b, ans = MOD;
    std::cin >> a >> b;
    a--;
    b--;
    if (a > b) std::swap(a, b);
    ll now = a, temp = 0;
    for (ll i = (1 << 19), pow = 19; i > 0; i /= 2, pow--) {
      if (max[pow][now] >= b) {
        ans = std::min(ans, temp + i);
      } else {
        temp += i;
        now = max[pow][now];
      }
    }
    std::cout << ans;
  }
  return 0;
}
