#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
int n, a[N], b[N], c[N], q, L;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> L;
  for (int i = n - 1; i >= 1; i--) {
    int l = i, r = n, d = a[i] + L;
    while (r - l > 1) {
      int md = (l + r) >> 1;
      if (a[md] > d)
        r = md;
      else
        l = md;
    }
    if (a[r] <= d) l = r;
    b[i] = b[l] + 1;
    c[i] = l;
  }
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    if (l > r) swap(l, r);
    int cnt = 0;
    while (l < r) {
      cnt++;
      l = c[l];
    }
    cout << cnt << endl;
  }
}
