#include <bits/stdc++.h>
using namespace std;
int n, L, q;
int arr[100005];
int MAX[100005];
int bin_search(int r, int val) {
  int logn = log(r) / log(2);
  for (int i = logn; i >= 0; i--) {
    int l = r - (1 << i);
    if (l <= 0)
      continue;
    else {
      if (val - arr[l] <= L) r -= (1 << i);
    }
  }
  return r;
}
int process(int i, int j) {
  if (arr[j] - arr[i] <= L)
    return 1;
  else
    return process(i, MAX[j]) + 1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  cin >> L;
  for (int i = 1; i <= n; i++) {
    int r = bin_search(i, arr[i]);
    MAX[i] = r;
  }
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (arr[b] - arr[a] <= L)
      cout << "1" << endl;
    else {
      cout << process(a, b) << endl;
    }
  }
}
