#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;
}
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 = floor(log2(N));
  vector<vector<long long>> next(LOG_N + 1, vector<long long>(N));
  for (int i = 0; i < N; i++) {
    auto it = lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin();
    if (it - 1 != i)
      next[0][i] = it - 1;
    else
      next[0][i] = LINF;
  }
  for (int k = 0; k < LOG_N; k++) {
    for (int i = 0; i < N; i++) {
      if (next[k][i] == LINF) {
        next[k + 1][i] = LINF;
      } else {
        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;
      long long p = _a;
      for (long long k = LOG_N - 1; k >= 0; k--) {
        if (p == -1) {
          break;
        }
        if ((m >> k) & 1) {
          p = next[k][p];
        }
      }
      if (p >= _b) {
        r = m;
      } else {
        l = m;
      }
    }
    cout << r << endl;
  }
}
int main(void) {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
