#include <bits/stdc++.h>
using namespace std;
namespace {
template <class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
  if (vs.empty()) return os << "[]";
  os << "[" << vs[0];
  for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
  return os << "]";
}
template <class T>
istream& operator>>(istream& is, vector<T>& vs) {
  for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
  return is;
}
int N, L, Q;
vector<int> X;
void input() {
  cin >> N;
  X.resize(N);
  cin >> X;
  cin >> L >> Q;
}
const int INF = 1 << 28;
void solve() {
  int logN = int(ceil(log2(N)));
  vector<vector<int>> dp(N, vector<int>(logN + 1, -1));
  for (int i = 0; i < N; i++) {
    auto it = upper_bound(X.begin(), X.end(), X[i] + L);
    dp[i][0] = it - X.begin() - 1;
  }
  for (int j = 1; j <= logN; j++) {
    for (int i = 0; i < N; i++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int k;
    for (k = 0; k <= logN; k++) {
      if (b <= dp[a][k]) {
        break;
      }
    }
    int c = dp[a][k - 1];
    for (int i = (1 << (k - 1)); i < (1 << k); i++) {
      if (b <= dp[c][0]) {
        cout << i << endl;
        break;
      }
    }
  }
}
}  // namespace
int main() {
  input();
  solve();
  return 0;
}
