#include <bits/stdc++.h>
using namespace std;
namespace std {
template <typename T, typename U>
struct hash<pair<T, U>> {
  hash<T> t;
  hash<U> u;
  size_t operator()(const pair<T, U> &p) const {
    return t(p.first) ^ (u(p.second) << 7);
  }
};
}  // namespace std
template <typename T, typename F>
T bsh(T l, T h, const F &f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      l = m + 1;
      r = m;
    } else {
      h = m - 1;
    }
  }
  return r;
}
template <typename T, typename F>
T bsl(T l, T h, const F &f) {
  T r = -1, m;
  while (l <= h) {
    m = (l + h) / 2;
    if (f(m)) {
      h = m - 1;
      r = m;
    } else {
      l = m + 1;
    }
  }
  return r;
}
template <typename T>
T gcd(T a, T b) {
  if (a < b) swap(a, b);
  return b ? gcd(b, a % b) : a;
}
template <typename T>
void fracn(pair<T, T> &a) {
  auto g = gcd(a.first, a.second);
  a.first /= g;
  a.second /= g;
}
template <typename T>
struct Index {
  int operator[](const T &t) {
    auto i = m.find(t);
    return i != m.end() ? i->second : m[t] = m.size();
  }
  int s() { return m.size(); }
  unordered_map<T, int> m;
};
int dist(const vector<int> &X, int B) {
  return bsl(0, (int)X.size() - 1, [&](int first) { return X[first] >= B; });
}
int dist2(const vector<int> &F, const vector<vector<int>> &M,
          const vector<int> &SQ, int A, int B) {
  if (A >= B) return 0;
  int lsq = SQ[bsh(0, (int)SQ.size() - 1, [&](int j) { return SQ[j] <= A; })];
  int hsq = SQ[bsl(0, (int)SQ.size() - 1, [&](int j) { return SQ[j] >= A; })];
  int lans = dist(M[lsq], B);
  if (lsq == hsq)
    return lans;
  else {
    int hans = dist(M[hsq], B);
    if (lans == hans)
      return lans;
    else
      return 1 + dist2(F, M, SQ, F[A], B);
  }
}
int main(int, char **) {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  ;
  vector<int> X(N);
  for (auto &_cinv : X) cin >> _cinv;
  ;
  int L;
  cin >> L;
  ;
  int Q;
  cin >> Q;
  ;
  vector<pair<int, int>> AB(Q);
  for (auto &q : AB) {
    cin >> q.first >> q.second;
    if (q.first > q.second) swap(q.first, q.second);
    --q.first;
    --q.second;
  }
  vector<int> F(N);
  for (int i = 0; i < N; ++i) {
    F[i] = bsh(i + 1, N - 1, [&](int j) { return X[j] <= X[i] + L; });
  }
  int SN = (int)sqrt(N);
  vector<vector<int>> M(N);
  vector<int> SQ;
  for (int i = 0; i < N; i += SN) {
    SQ.push_back(i);
    for (int first = i; first != -1; first = F[first]) {
      M[i].push_back(first);
    }
    M[i].push_back(N);
  }
  for (int i = 0; i < Q; i++) {
    cout << dist2(F, M, SQ, AB[i].first, AB[i].second) << endl;
  }
}
