#include <bits/stdc++.h>
using namespace std;
const long long INF = INT_MAX;
const long long MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (long long i = 0; (i) < (N); ++(i)) cin >> x[i];
  x.push_back(INF);
  long long L;
  cin >> L;
  vector<vector<int> > rmax(20, vector<int>(N, 0));
  for (long long i = 0; (i) < (N); ++(i)) {
    rmax[0][i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  for (long long k = 0; (k) < (18); ++(k)) {
    for (long long i = 0; (i) < (N); ++(i)) {
      rmax[k + 1][i] = rmax[k][rmax[k][i]];
    }
  }
  for (long long i = 0; (i) < (N); ++(i))
    cerr << "rmax[0]"
         << "[" << i << "]: " << rmax[0][i] << '\n';
  int Q;
  cin >> Q;
  for (long long q = 0; (q) < (Q); ++(q)) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (int k = 18; k >= 0; k--) {
      if (rmax[k][a] >= b) continue;
      ans |= 1 << k;
      a = rmax[k][a];
    }
    ans++;
    cout << ans << endl;
  }
  cerr << bitset<20>(524287) << endl;
  return 0;
}
