#include <bits/stdc++.h>
using namespace std;
int x[100005];
int sps[100005][20];
signed main() {
  int n, q, L;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  cin >> L >> q;
  int p = n;
  for (int i = n; i >= 1; i--) {
    while (x[p] - x[i] > L) p--;
    sps[i][0] = p;
  }
  for (int d = 1; d <= 15; d++) {
    for (int i = 1; i + (1 << d) <= n; i++)
      sps[i][d] = sps[sps[i][d - 1]][d - 1];
  }
  while (q--) {
    int l, r, ans = 0;
    cin >> l >> r;
    if (l > r) swap(l, r);
    for (int i = 15; i >= 0; i--) {
      if (sps[l][i] < r and sps[l][i]) {
        l = sps[l][i];
        ans += (1 << i);
      }
    }
    ans++;
    cout << ans << endl;
  }
}
