#include <bits/stdc++.h>
using namespace std;
using Pint = pair<int, int>;
int N, L, Q;
vector<int> x;
vector<Pint> q;
int main() {
  cin >> N;
  x.resize(N);
  for (auto &val : x) cin >> val;
  x.push_back(x[N - 1] + 1);
  cin >> L >> Q;
  q.resize(Q);
  for (int i = 0; i < Q; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    if (t1 > t2) swap(t1, t2);
    q[i] = Pint(t1 - 1, t2 - 1);
  }
  int lgN = 0;
  {
    int tmp = N;
    while (tmp) {
      lgN++;
      tmp /= 2;
    }
  }
  vector<vector<int> > next(lgN + 1, vector<int>(N));
  for (int i = 0; i < N; i++) {
    next[1][i] = min(
        (int)(lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin()) - 1,
        N - 1);
  }
  for (int n = 2; n <= lgN; n++) {
    for (int i = 0; i < N; i++) {
      next[n][i] = next[n - 1][next[n - 1][i]];
    }
  }
  for (auto query : q) {
    int ans = 0;
    int now = query.first;
    for (int n = lgN; n > 0; n--) {
      if (next[n][now] < query.second) {
        ans += n;
        now = next[n][now];
      }
    }
    cout << ans + 1 << endl;
  }
}
