#include <bits/stdc++.h>
using namespace std;
const int vx[4] = {0, 1, 0, -1};
const int vy[4] = {1, 0, -1, 0};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = (long long)0; i < (long long)n; i++) {
    cin >> a[i];
  }
  vector<long long> dr(n, INT_MAX);
  dr[0] = 0;
  long long l, q;
  cin >> l >> q;
  for (long long i = (long long)0; i < (long long)n; i++) {
    long long it = upper_bound(a.begin(), a.end(), a[i] + l) - a.begin();
    for (long long j = (long long)it - 1; j >= (long long)0; j--) {
      if (dr[i] + 1 >= dr[j]) break;
      dr[j] = dr[i] + 1;
    }
  }
  for (long long i = (long long)0; i < (long long)n; i++) {
    cout << dr[i] << ' ';
  }
  cout << endl;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if (x > y) swap(x, y);
    cout << max(1LL, dr[y] - dr[x]) << endl;
  }
}
