#include <bits/stdc++.h>
using namespace std;
int n, i, a[100002], dis[100002], l, q, r[100002];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> l >> q;
  for (i = 1; i <= n; i++) {
    int pos = lower_bound(a + 1, a + n + 1, a[i] + l) - a;
    if (a[pos] == a[i] + l)
      r[i] = pos;
    else
      r[i] = pos - 1;
  }
  for (i = 1; i <= q; i++) {
    int x, y, cnt = 0;
    cin >> x >> y;
    if (x > y) swap(x, y);
    while (x < y) x = r[x], cnt++;
    cout << cnt << endl;
  }
  return 0;
}
