#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int x[N];
  for (int i = 0; i < N; ++i) cin >> x[i];
  int L;
  cin >> L;
  int table[N][30];
  for (int i = 0; i < N; ++i) {
    fill(table[i], table[i] + 30, 0);
    table[i][0] = upper_bound(x, x + N, x[i] + L) - x - 1;
  }
  for (int j = 1; j < 30; ++j) {
    for (int i = 0; i < N; ++i) {
      table[i][j] = table[table[i][j - 1]][j - 1];
    }
  }
  int Q;
  cin >> Q;
  int a, b;
  for (int i = 0; i < Q; ++i) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    --a;
    --b;
    int ans = 0, r = 29;
    while (r > 0) {
      while (r >= 0 && table[a][r] >= b) --r;
      if (r >= 0) ans += 1 << r;
      a = table[a][r];
    }
    ++ans;
    cout << ans << endl;
  }
  return 0;
}
