#include <bits/stdc++.h>
using namespace std;
long long n, q, kc;
long long a[200001];
long long chat(long long x, long long y, long long u, long long v) {
  long long l = u, r = v;
  long long z = x + kc;
  if (z > y) return 1;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (a[mid] < z)
      l = mid + 1;
    else if (a[mid] == z)
      return chat(a[mid], y, mid, v);
    else
      r = mid;
  }
  return chat(a[l - 1], y, l - 1, v) + 1;
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> kc >> q;
  long long x, y;
  while (q--) {
    cin >> x >> y;
    cout << chat(a[min(x, y)], a[max(x, y)], min(x, y), max(x, y)) << "\n";
  }
}
