#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, a[maxn], l, q;
int f[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> l;
  for (int i = 1; i <= n; i++) {
    int idx = upper_bound(a + 1, a + 1 + n, a[i] + l) - a - 1;
    if (a[i] + l >= a[n])
      f[i] = n;
    else
      f[i] = idx;
  }
  cin >> q;
  while (q--) {
    long long u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    long long dem;
    dem = 0;
    while (u < v) {
      dem++;
      u = f[u];
    }
    cout << dem << endl;
  }
}
