#include <bits/stdc++.h>
using namespace std;
const int INF = 0x0fffffff;
int N;
int X[101010];
int r[101010][20];
int L;
int Q;
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }
  cin >> L;
  for (int i = 0; i < N; ++i) {
    r[i][0] = lower_bound(X + i, X + N, X[i] + L + 1) - 1 - X;
  }
  for (int j = 0; j < 19; ++j) {
    for (int i = 0; i < N; ++i) {
      r[i][j + 1] = r[r[i][j]][j];
    }
  }
  cin >> Q;
  while (Q--) {
    int a;
    int b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      swap(a, b);
    }
    int ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (r[a][i] < b) {
        b = b - r[a][i];
        ans += 1 << i;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
