#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < (int)(N); ++i) cin >> x[i];
  cin >> L;
  cin >> Q;
  vector<int> a(Q), b(Q);
  for (int i = 0; i < (int)(Q); ++i) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
  }
  vector<int> dp(N);
  dp[0] = 0;
  int left = 0, right = 1;
  while (right < N) {
    while (right < N and x[right] - x[left] <= L) {
      dp[right] = dp[left] + 1;
      ++right;
    }
    left = right - 1;
  }
  int ans = 0;
  for (int i = 0; i < (int)(Q); ++i) {
    if (abs(x[a[i]] - x[b[i]]) <= L)
      cout << 1 << endl;
    else
      cout << abs(dp[a[i]] - dp[b[i]]) << endl;
  }
  return 0;
}
