#include <bits/stdc++.h>
using namespace std;
long long n, l, q, a, b, v[100010][32];
vector<long long> x;
int main() {
  cin >> n;
  x.resize(n + 2);
  for (int i = 1; i <= n; ++i) cin >> x[i];
  x[0] = -1;
  x[n + 1] = 1e18 + 9;
  cin >> l;
  for (int i = 1; i <= n; ++i)
    v[i][0] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  for (int i = 1; i < 20; ++i)
    for (int j = 1; j <= n; ++j) v[j][i] = v[v[j][i - 1]][i - 1];
  cin >> q;
  while (q--) {
    cin >> a >> b;
    long long ans = 0;
    if (a > b) swap(a, b);
    for (int i = 19; i >= 0; --i) {
      if (v[a][i] <= b) {
        a = v[a][i];
        ans += 1 << i;
      }
    }
    cout << ans << "\n";
  }
}
