#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  vector<long long> X;
  long long L;
  cin >> N;
  X.resize(N);
  for (long long i = 0; i < N; ++i) {
    cin >> X[i];
  }
  sort(X.begin(), X.end());
  cin >> L;
  vector<vector<long long> > d;
  d.resize(N);
  for (long long i = 0; i < N; ++i) {
    d[i].resize(32);
  }
  for (long long i = 0; i < N; ++i) {
    d[i][0] = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin() - 1;
  }
  for (long long j = 1; j < 32; ++j) {
    for (long long i = 0; i < N; ++i) {
      d[i][j] = d[d[i][j - 1]][j - 1];
    }
  }
  long long Q;
  cin >> Q;
  while (Q--) {
    long long a;
    long long b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    long long s = 0;
    for (long long i = 31; i >= 0; --i) {
      if (d[a][i] == b) {
        a = d[a][i];
        s += (1LL << i);
        break;
      } else if (i == 0 && d[a][i] < b) {
        a = d[a][i];
        s += (1LL << i);
        break;
      } else if (d[a][i] < b) {
        a = d[a][i];
        s += (1LL << i);
      }
    }
    cout << s << endl;
  }
}
