#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int64_t inf64 = 1e18;
const double eps = 1e-9;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
using i64 = int64_t;
void solve() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = (0); i < (N); ++i) cin >> x[i];
  int L;
  cin >> L;
  vector<vector<int>> jump(N, vector<int>(17));
  vector<int> pow(17);
  {
    int j = 1;
    for (int i = (0); i < (N); ++i) {
      while (j < N and x[j] - x[i] <= L) ++j;
      jump[i][0] = j - 1;
    }
    pow[0] = 1;
    for (int j = (1); j < (17); ++j) {
      for (int i = (0); i < (N); ++i) jump[i][j] = jump[jump[i][j - 1]][j - 1];
      pow[j] = pow[j - 1] * 2;
    }
  }
  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);
    function<int(int)> ans = [&](int pos) {
      if (pos >= b) return 0;
      for (int j = 16; j >= 0; --j)
        if (jump[pos][j] <= b) return ans(jump[pos][j]) + pow[j];
    };
    cout << ans(a) << endl;
  }
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  solve();
  return 0;
}
