#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  long long l, q;
  cin >> l >> q;
  vector<long long> x(q), y(q);
  for (long long i = (0); i < (q); i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
    if (x[i] > y[i]) swap(x[i], y[i]);
  }
  long long m = log2(n) + 1;
  vector<vector<long long>> tmp(n, vector<long long>(m, (1LL << 60)));
  for (long long i = (0); i < (n); i++)
    tmp[i][0] = upper_bound(a.begin(), a.end(), a[i] + l) - a.begin() - 1;
  for (long long i = (0); i < (m - 1); i++) {
    for (long long j = (0); j < (n); j++) {
      long long id = j;
      for (long long k = (0); k < (i + 1); k++) id = tmp[id][k];
      tmp[j][i + 1] = tmp[id][0];
    }
  }
  for (long long i = (0); i < (q); i++) {
    long long ans = 0, pos = x[i];
    while (pos < y[i]) {
      long long id = upper_bound(tmp[pos].begin(), tmp[pos].end(), y[i]) -
                     tmp[pos].begin() - 1;
      pos = tmp[pos][id];
      ans += (1 << id);
    }
    cout << ans << endl;
  }
  return 0;
}
