#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  long long int L;
  cin >> N;
  vector<long long int> x(N + 1);
  for (int i = int(0); i < int(N); i++) {
    cin >> x[i];
  }
  x[N] = (1 << 30) - 1;
  cin >> L;
  vector<vector<long long int> > v(N + 5,
                                   vector<long long int>(18, (1 << 30) - 1));
  int X = (1 << 30) - 1;
  for (int i = int(0); i < int(N); i++) {
    auto it = upper_bound(begin(x), end(x), L + x[i]);
    int next = it - 1 - x.begin();
    if (next == i)
      v[i][0] = X;
    else
      v[i][0] = next;
  }
  for (int k = 1; k < v[0].size(); k++) {
    for (int i = 0; i < N; i++) {
      if (v[i][k - 1] != X) v[i][k] = v[v[i][k - 1]][k - 1];
    }
  }
  int Q;
  cin >> Q;
  for (int i = int(0); i < int(Q); i++) {
    int a, b;
    cin >> a >> b;
    if (b < a) swap(a, b);
    a--;
    b--;
    long long int ans = 0;
    int cur = a;
    for (int j = v[0].size() - 1; j >= 0; j--) {
      if (v[cur][j] > b) {
      } else {
        ans += (1 << j);
        cur = v[cur][j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
