#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
long long x[100000];
long long nxt[31][100001];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> x[i];
  long long L;
  cin >> L;
  for (int i = 0; i <= 30; i++) nxt[i][N] = N;
  nxt[0][N - 1] = N;
  for (int i = 0; i + 1 < N; i++) {
    nxt[0][i] = upper_bound(x, x + N, x[i] + L) - x - 1;
  }
  for (int i = 0; i < 30; i++) {
    for (int j = 0; j < N; j++) {
      nxt[i + 1][j] = nxt[i][nxt[i][j]];
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int now = a;
    long long ans = 0;
    for (int j = 30; j >= 0; j--) {
      if (nxt[j][now] <= b) {
        now = nxt[j][now];
        ans += (1LL << j);
      }
    }
    cout << ans << endl;
  }
}
