#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& o) {
  out << "(" << o.first << "," << o.second << ")";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T> V) {
  for (int i = 0; i < V.size(); i++) {
    out << V[i];
    if (i != V.size() - 1) out << " ";
  }
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<vector<T>> Mat) {
  for (int i = 0; i < Mat.size(); i++) {
    if (i != 0) out << endl;
    out << Mat[i];
  }
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const map<S, T> mp) {
  out << "{ ";
  for (auto it = mp.begin(); it != mp.end(); it++) {
    out << it->first << ":" << it->second;
    if (mp.size() - 1 != distance(mp.begin(), it)) out << ", ";
  }
  out << " }";
  return out;
}
long long check(long long i, long long d, vector<vector<long long>>& next) {
  if (d == 0) return i;
  long long k = 0;
  while (d >= (1 << k)) k++;
  return check(next[k - 1][i], d - (1 << (k - 1)), next);
}
void solve() {
  long long N;
  cin >> N;
  vector<long long> x(N);
  for (auto& in : x) cin >> in;
  long long L;
  cin >> L;
  long long Q;
  cin >> Q;
  vector<long long> a(Q), b(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  long long LOG_N = 0;
  while (N >= (1 << LOG_N)) LOG_N++;
  vector<vector<long long>> next(LOG_N, vector<long long>(N));
  for (int i = 0; i < N; i++) {
    next[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  for (int k = 0; k < LOG_N; k++) {
    for (int i = 0; i < N; i++) {
      next[k + 1][i] = next[k][next[k][i]];
    }
  }
  for (int i = 0; i < Q; i++) {
    long long _a = a[i], _b = b[i];
    long long l = 0, r = N;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (check(_a, m, next) >= _b)
        r = m;
      else
        l = m;
    }
    cout << r << endl;
  }
}
int main(void) {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
