#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 1);
  for (int i = 0; i < n; i++) cin >> x[i];
  int L;
  cin >> L;
  vector<vector<int>> grh(31, vector<int>(n + 1));
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (j < n && x[i] + L >= x[j]) j++;
    grh[0][i] = j - 1;
  }
  grh[0][n - 1] = grh[0][n] = n;
  for (int p = 1; p < 31; p++) {
    for (int i = 0; i <= n; i++) {
      grh[p][i] = grh[p - 1][grh[p - 1][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ret = 0;
    for (int p = 31 - 1; p >= 0; p--) {
      if (grh[p][a] <= b) {
        a = grh[p][a];
        ret += (1 << p);
      }
    }
    cout << ret << '\n';
  }
  return 0;
}
