#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int x[100100];
long long int l;
inline long long int solve(long long int a, long long int b) {
  if (a > b) swap(a, b);
  long long int pos = a;
  long long int res = 0;
  while (pos != b) {
    res++;
    if (x[b] - x[pos] <= l) {
      pos = b;
      continue;
    }
    long long int* new_pos = upper_bound(x, x + n, x[pos] + l);
    pos = (long long int)(new_pos - 1 - x);
  }
  return res;
}
int main() {
  cin >> n;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    cin >> x[i];
  }
  long long int q;
  cin >> l >> q;
  for (long long int i = 0; i < ((long long int)(q)); i++) {
    long long int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << solve(a, b) << endl;
  }
  return 0;
}
