#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int N;
vector<long long> X;
long long L;
int Q;
int nxt[20][100010];
const long long INF = 1e15;
int main() {
  cin >> N;
  X.resize(N);
  for (int i = 0; i < (N); ++i) cin >> X[i];
  cin >> L;
  X.push_back(INF);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 20; j++) nxt[i][j] = -1;
  for (int i = 0; i < N; i++) {
    int z = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin();
    z--;
    nxt[0][i] = z;
  }
  nxt[0][N - 1] = -1;
  for (int k = 0; k + 1 < 20; k++) {
    for (int i = 0; i < N; i++) {
      if (nxt[k][i] == -1) continue;
      nxt[k + 1][i] = nxt[k][nxt[k][i]];
    }
  }
  cin >> Q;
  vector<int> ans(Q, 0);
  for (int q = 0; q < Q; q++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ok = N, ng = 0;
    while (ok - ng > 1) {
      int mid = (ok + ng) / 2;
      int now = a;
      for (int k = 0; k < 20; k++) {
        if (mid & (1 << k)) {
          now = nxt[k][now];
          if (now == -1) break;
        }
      }
      if (now >= b || now == -1)
        ok = mid;
      else
        ng = mid;
    }
    ans[q] = ok;
  }
  for (int i = 0; i < Q; i++) cout << ans[i] << endl;
  return 0;
}
