#include <bits/stdc++.h>
using namespace std;
bool LT(double a, double b) { return !(fabs((a) - (b)) < (1e-8)) && a < b; }
bool LTE(double a, double b) { return (fabs((a) - (b)) < (1e-8)) || a < b; }
long long N, Q, L;
long long x[100010], a, b;
int nex[100010][70];
void compute() {
  for (int i = 0; i < N; ++i)
    nex[i][0] = (upper_bound(x, x + N, x[i] + L) - x) - 1;
  for (int j = 0; j < 67; ++j)
    for (int i = 0; i < N; ++i) nex[i][j + 1] = nex[nex[i][j]][j];
  cin >> Q;
  for (int _ = 0; _ < Q; ++_) {
    cin >> a >> b;
    --a, --b;
    if (!(a < b)) swap(a, b);
    long long cost = 0;
    while (a != b) {
      int go = 0;
      while (nex[a][go] <= b) ++go;
      --go;
      cost += (1LL << go);
      a = nex[a][go];
    }
    cout << cost << endl;
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> x[i];
  cin >> L;
  compute();
  return 0;
}
