#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void output(T a, int p) {
  if (p)
    cout << fixed << setprecision(p) << a << "\n";
  else
    cout << a << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<long long> X(N);
  for (int i = (int)(0); i < (int)(N); i++) cin >> X[i];
  long long L;
  cin >> L;
  vector<int> B(N);
  for (int i = (int)(0); i < (int)(N - 1); i++) {
    int l = i + 1, r = N;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (X[mid] - X[i] <= L)
        l = mid;
      else
        r = mid;
    }
    B[i] = l;
  }
  int Q;
  cin >> Q;
  vector<pair<int, int>> A(Q);
  for (int i = (int)(0); i < (int)(Q); i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--, b--;
    A[i] = make_pair(a, b);
  }
  for (int i = (int)(0); i < (int)(Q); i++) {
    int ret = 0;
    for (int j = A[i].first; j < A[i].second; j = B[j], ret++) {
    }
    output(ret, 0);
  }
  return 0;
}
