#include <bits/stdc++.h>
using namespace std;
int N, L, Q;
int x[100005];
int Next[17][100005];
int main(void) {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> x[i];
  x[N] = x[N - 1] + 1;
  cin >> L;
  int p;
  for (int i = 0; i <= N; i++) {
    Next[0][i] = upper_bound(x, x + N + 1, x[i] + L) - x - 1;
  }
  for (int i = 1; i < 17; i++) {
    for (int j = 0; j <= N; j++) {
      Next[i][j] = Next[i - 1][Next[i - 1][j]];
    }
  }
  cin >> Q;
  int a, b;
  for (int q = 0; q < Q; q++) {
    cin >> a >> b;
    a--, b--;
    if (a > b) {
      int t = a;
      a = b, b = t;
    }
    int cur = a, ans = 0;
    for (int i = 16; i >= 0; i--) {
      if (Next[i][cur] <= b) {
        cur = Next[i][cur];
        ans += 1 << i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
