#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
template <class T>
inline void chmax(T &a, const T &b) {
  if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
  if ((a) > (b)) (a) = (b);
}
template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
void check_input() {
  assert(cin.eof() == 0);
  int tmp;
  cin >> tmp;
  assert(cin.eof() == 1);
}
signed main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (long long n = (long long)(0); n < (long long)(N); ++n) cin >> x[n];
  int L;
  cin >> L;
  int Q;
  cin >> Q;
  vector<vector<int>> db(N, vector<int>(20));
  for (long long n = (long long)(0); n < (long long)(N); ++n) {
    db[n][0] = (upper_bound((x).begin(), (x).end(), x[n] + L) - x.begin()) - 1;
  }
  for (long long k = (long long)(1); k < (long long)(20); ++k) {
    for (long long n = (long long)(0); n < (long long)(N); ++n) {
      db[n][k] = db[db[n][k - 1]][k - 1];
    }
  }
  for (long long q = (long long)(0); q < (long long)(Q); ++q) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    ;
    ;
    int ans = 0;
    while (a != b) {
      ;
      ;
      int k =
          (upper_bound((db[a]).begin(), (db[a]).end(), b) - db[a].begin()) - 1;
      ans += pow(2, k);
      a = db[a][k];
    }
    cout << ans << endl;
  }
  return 0;
}
