#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int x[N];
  for (int i = 0; i < (int)(N); i++) cin >> x[i];
  long long L;
  cin >> L;
  int logN = (int)log2(N);
  int doub[N][logN + 1];
  for (int i = 0; i < (int)(N); i++)
    doub[i][0] = upper_bound(x, x + N, x[i] + L) - x - 1;
  doub[N - 1][0] = -1;
  for (int k = 0; k < (int)(logN); k++)
    for (int i = 0; i < (int)(N); i++) {
      if (doub[i][k] != -1)
        doub[i][k + 1] = doub[doub[i][k]][k];
      else
        doub[i][k + 1] = -1;
    }
  int q;
  cin >> q;
  for (int i = 0; i < (int)(q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    int now = a;
    for (int j = logN - 1; j >= 0; j--) {
      if (doub[now][j] >= 0 && doub[now][j] <= b) {
        ans += 1 << j;
        now = doub[now][j];
      }
    }
    if (now != b) ans++;
    cout << ans << endl;
  }
  return 0;
}
