#include <bits/stdc++.h>
using namespace std;
vector<long long> x;
vector<vector<long long> > gp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, l, q;
  cin >> n;
  gp.resize(n, vector<long long>(18));
  x.resize(n);
  for (long long i = 0; i < (n); ++i) cin >> x[i];
  cin >> l >> q;
  long long cn = 0;
  for (long long i = 0; i < (n); ++i) {
    while (cn < n && x[cn] <= x[i] + l) ++cn;
    gp[i][0] = cn - 1;
  }
  for (long long i = 1; i < 18; ++i) {
    for (long long j = 0; j < (n); ++j) gp[j][i] = gp[gp[j][i - 1]][i - 1];
  }
  long long a, b;
  for (long long z = 0; z < (q); ++z) {
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    long long sm = 0;
    for (long long i = 17; i >= 0; --i) {
      if (gp[a][i] <= b) {
        sm += (1LL << i);
        a = gp[a][i];
      }
    }
    if (a != b) ++sm;
    cout << sm << endl;
  }
  return 0;
}
