#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 62;
const int inf = 1 << 30;
const char bn = '\n';
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  int N = V.size();
  for (int i = 0; i < (N); i++) {
    os << V[i];
    if (i != N - 1) os << " ";
  }
  os << "\n";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> const& P) {
  os << "(";
  os << P.first;
  os << " , ";
  os << P.second;
  os << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& S) {
  auto it = S.begin();
  while (it != S.end()) {
    os << *it;
    os << " ";
    it++;
  }
  os << "\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T>& q) {
  for (auto it = q.begin(); it < q.end(); it++) {
    os << *it;
    os << " ";
  }
  os << endl;
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, map<T, S> const& M) {
  for (auto e : M) {
    os << e;
  }
  os << endl;
  return os;
}
vector<pair<int, int>> dxdy = {make_pair(0, 1), make_pair(1, 0),
                               make_pair(-1, 0), make_pair(0, -1)};
int calc_next(long long x, vector<long long> const& X) {
  return (upper_bound((X).begin(), (X).end(), x) - X.begin()) - 1;
}
vector<vector<int>> doubling(vector<int> const& to, long long MAX_K) {
  int J = 1;
  while (MAX_K > 0) {
    J++;
    MAX_K >>= 1;
  }
  size_t N = to.size();
  vector<vector<int>> DP(N, vector<int>(J));
  for (int i = 0; i < N; i++) DP[i][0] = to[i];
  for (int j = 1; j < J; j++) {
    for (int i = 0; i < N; i++) {
      DP[i][j] = DP[DP[i][j - 1]][j - 1];
    }
  }
  return move(DP);
}
int solve(int a, int b, vector<vector<int>> const& DP) {
  int res = 0;
  int now = a;
  while (now < b) {
    auto idx =
        lower_bound((DP[now]).begin(), (DP[now]).end(), b) - DP[now].begin();
    res += 1 << idx;
    now = DP[now][idx];
  }
  return res;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> X(N);
  for (int i = 0; i < (N); i++) cin >> X[i];
  long long L;
  cin >> L;
  vector<int> to(N);
  for (int i = 0; i < (N); i++) {
    to[i] = calc_next(X[i] + L, X);
  }
  auto DP = doubling(to, 1e5);
  int Q;
  cin >> Q;
  for (int i = 0; i < (Q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    auto ans = solve(a, b, DP);
    cout << ans << bn;
  }
}
