#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(const T& x) {
  cout << x << endl;
}
template <class T, class... A>
void print(const T& first, const A&... rest) {
  cout << first << " ";
  print(rest...);
}
struct PreMain {
  PreMain() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} premain;
int main() {
  int N;
  cin >> N;
  vector<long long> X(N);
  for (int(i) = 0; (i) < (int)(N); ++(i)) cin >> X[i];
  long long L;
  cin >> L;
  int tmp = 0;
  int log_n = (int)log2(N) + 1;
  vector<vector<int>> next(log_n + 1, vector<int>(N + 1, 0));
  for (int(i) = 0; (i) < (int)(N); ++(i)) {
    while (tmp < N - 1 && X[tmp + 1] - X[i] <= L) tmp++;
    next[0][i] = tmp;
  }
  next[0][N - 1] = N;
  next[0][N] = N;
  for (int(k) = 0; (k) < (int)(log_n); ++(k)) {
    for (int(i) = 0; (i) < (int)(N + 1); ++(i)) {
      next[k + 1][i] = next[k][next[k][i]];
    }
  }
  int Q;
  cin >> Q;
  for (int(i) = 0; (i) < (int)(Q); ++(i)) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int j = a;
    int ans = 0;
    for (int(k) = (int)(log_n + 1) - 1; (k) >= 0; --(k)) {
      if (next[k][j] <= b) {
        j = next[k][j];
        ans += 1 << k;
      }
    }
    print(ans);
  }
  return 0;
}
