#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];
  int len;
  cin >> len;
  vector<vector<int> > to(n);
  int k = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    while (x[k] - x[i] > len) --k;
    to[i].push_back(k);
    for (unsigned j = 0; j < to[to[i][j]].size(); ++j)
      to[i].push_back(to[to[i][j]][j]);
  }
  int q;
  cin >> q;
  while (--q >= 0) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    int ans = 0;
    while (a < b) {
      unsigned i = 0;
      while (i < to[a].size() && to[a][i] <= b) ++i;
      --i;
      ans += 1 << i;
      a = to[a][i];
    }
    cout << ans << endl;
  }
  return 0;
}
