#include <bits/stdc++.h>
using namespace std;
long n, l, q;
long x[1010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  cin >> l;
  cin >> q;
  while (q--) {
    int a, b, ans = 0;
    cin >> a >> b;
    if (a > b) {
      int rem = a;
      a = b;
      b = rem;
    }
    while (a != b) {
      a = lower_bound(x + a + 1, x + n + 1, x[a] + l + 1) - x - 1;
      ans++;
    }
    cout << ans << endl;
  }
}
