#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ch = char;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge {
  ll to, cost;
};
struct edge2 {
  ll from, to, cost;
};
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MXN = 100001;
vector<ll> G[MXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  X.push_back(INF);
  int L;
  cin >> L;
  for (int i = 0; i < N; i++) {
    auto itr = upper_bound(X.begin(), X.end(), X[i] + L);
    itr--;
    ll k = itr - X.begin();
    G[i].push_back(k);
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ll cnt = 0;
    if (a > b) {
      swap(a, b);
    }
    while (b > a) {
      cnt++;
      a = G[a][0];
    }
    cout << cnt << endl;
  }
}
