#include <bits/stdc++.h>
using namespace std;
long long n, x[100005], l, q, test, sparse[100005][19];
long long binser(long long tmp) {
  if (tmp > x[n]) return n + 1;
  long long l1 = 1, r = n;
  while (l1 < r - 1) {
    long long mid = (l1 + r) >> 1;
    if (x[mid] <= tmp)
      l1 = mid;
    else
      r = mid;
  }
  if (x[r] <= tmp) l1 = r;
  return l1;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> x[i];
  cin >> l >> q;
  for (long long i = 1; i <= n; i++) sparse[i][0] = binser(x[i] + l);
  for (long long i = 1; i <= n; i++) cout << sparse[i][0] << " ";
  cout << endl;
  for (long long i = 0; i <= 18; i++) sparse[n + 1][i] = n + 1;
  for (long long i = 1; i <= 18; i++) {
    for (long long j = 1; j <= n; j++) {
      sparse[j][i] = sparse[sparse[j][i - 1]][i - 1];
    }
  }
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long i = 18; i >= 0; i--) {
      if (sparse[a][i] <= b) {
        ans += 1 << i;
        a = sparse[a][i];
      }
    }
    cout << ans << "\n";
  }
}
