#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int &t : x) cin >> t;
  int L;
  cin >> L;
  int D = 1;
  while ((1 << D) < N - 1) D++;
  vector<vector<int>> T(N, vector<int>(D + 1));
  int s = 0;
  int t = 1;
  int l = x[1] - x[0];
  while (s < N - 1) {
    if (t < N - 1 && l + x[t + 1] - x[t] <= L) {
      l += x[t + 1] - x[t];
      t++;
    } else {
      l -= x[s + 1] - x[s];
      T[s][0] = t - s;
      s++;
    }
  }
  for (int d = 1; d <= D; d++)
    for (int i = 0; i < N; i++)
      T[i][d] = T[i][d - 1] + T[i + T[i][d - 1]][d - 1];
  int Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    while (a < b) {
      int d = 0;
      while (a + T[a][d] < b) d++;
      ans += 1 << d;
      a += T[a][d];
    }
    cout << ans << endl;
  }
}
