#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int N, Q, L;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X[i];
  cin >> L >> Q;
  vector<vector<int> > lft(20, vector<int>(N)), rt(20, vector<int>(N));
  for (int i = 0; i < N; i++) {
    int akt = i;
    while (akt < N && X[akt] - X[i] <= L) akt++;
    rt[0][i] = akt - 1;
    akt = i;
    while (akt >= 0 && X[i] - X[akt] <= L) akt--;
    lft[0][i] = akt + 1;
  }
  for (int k = 1; k < 20; k++)
    for (int i = 0; i < N; i++) {
      lft[k][i] = lft[k - 1][lft[k - 1][i]];
      rt[k][i] = rt[k - 1][rt[k - 1][i]];
    }
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    int ans = 0;
    for (int k = 19; k >= 0; k--) {
      if (a < b && rt[k][a] < b) {
        ans += 1 << k;
        a = rt[k][a];
      } else if (a > b && lft[k][a] > b) {
        ans += 1 << k;
        a = lft[k][a];
      }
    }
    if (a != b) ans++;
    cout << ans << "\n";
  }
  return 0;
}
