#include <bits/stdc++.h>
using namespace std;
void solve() {
  int N, L, Q;
  cin >> N;
  vector<int> xs(N);
  for (int i = 0; i < N; i++) {
    cin >> xs[i];
  }
  cin >> L >> Q;
  vector<vector<int>> memo(20, vector<int>(N, N - 1));
  for (int i = N - 1; i >= 0; i--) {
    int ok = i, ng = N;
    while (ok + 1 < ng) {
      int m = (ok + ng) / 2;
      (xs[i] + L >= xs[m] ? ok : ng) = m;
    }
    memo[0][i] = ok;
    int pos = ok;
    for (int j = 0; j < 19; j++) {
      pos = memo[j + 1][i] = memo[j][pos];
    }
  }
  while (Q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    while (a < b) {
      int ok = 19, ng = -1;
      while (ok > ng + 1) {
        int m = (ok + ng) / 2;
        (memo[m][a] >= b ? ok : ng) = m;
      }
      a = memo[ok][a];
      ans += pow(2, ok);
    }
    cout << ans << endl;
  }
}
int main(void) {
  solve();
  return 0;
}
