#include <bits/stdc++.h>
using namespace std;
int n;
int x[111111];
int r[33][111111];
int l, q;
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = (int)(0); i < (int)(n); i++) cin >> x[i];
  cin >> l;
  for (int i = (int)(0); i < (int)(n); i++) {
    r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
  }
  for (int i = (int)(0); i < (int)(33); i++) {
    for (int j = (int)(0); j < (int)(n); j++) {
      r[i + 1][j] = r[i][r[i][j]];
    }
  }
  cin >> q;
  for (int i = (int)(0); i < (int)(q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int res = 0;
    int ns = a;
    for (int k = 33; k >= 0; k--) {
      if (ns == b) break;
      if (r[k][ns] <= b) {
        ns = r[k][ns];
        res |= 1 << k;
      }
    }
    cout << res << endl;
  }
  return 0;
}
