#include <bits/stdc++.h>
using namespace std;
vector<int> x;
int l;
int solve(int a, int b) {
  a--, b--;
  if (a > b) swap(a, b);
  int tmp = x[a];
  int c = 0;
  while (tmp < x[b]) {
    c++;
    tmp = x[upper_bound((x).begin(), (x).end(), tmp + l) - x.begin() - 1];
  }
  return c;
}
int main() {
  int n;
  cin >> n;
  x.resize(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> x[i];
  int q;
  cin >> l >> q;
  for (long long i = 0; i < (long long)(q); i++) {
    int a, b;
    cin >> a >> b;
    cout << solve(a, b) << endl;
  }
}
