#include <bits/stdc++.h>
using namespace std;
int n, q, L, x[1 << 17];
int d[20][1 << 17];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> L;
  for (int i = 0; i < n; i++) {
    d[0][i] = upper_bound(x, x + n, x[i] + L) - x - 1;
  }
  for (int k = 1; k < 20; k++) {
    for (int i = 0; i < n; i++) {
      d[k][i] = d[k - 1][d[k - 1][i]];
    }
  }
  cin >> q;
  for (; q--;) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int k = 20; k--;) {
      if (d[k][a] <= b) {
        ans += 1 << k;
        a = d[k][a];
      }
    }
    cout << ans << endl;
  }
}
