#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int N;
int main() {
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  for (int i = 0; i < (int)(N); i++) {
    cin >> x.at(i);
  }
  int L;
  cin >> L;
  int pos = 1;
  for (int i = 0; i < (int)(N - 1); i++) {
    while (pos < N && x.at(pos) <= x.at(i) + L) {
      pos++;
    }
    y.at(i) = pos - 1;
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < (int)(Q); i++) {
    int ans = 0;
    int a, b;
    cin >> a >> b;
    if (a > b) {
      int tmp = b;
      b = a;
      a = tmp;
    }
    while (a < b) {
      a = y.at(a - 1) + 1;
      ans++;
    }
    cout << ans << endl;
  }
}
