#include <bits/stdc++.h>
using namespace std;
int N, L;
const int MAX_N = 100010;
int a[MAX_N], b[MAX_N][20];
void init() {
  a[N] = 1e9 + 1;
  for (int i = N - 1, j = N; i >= 0; i--) {
    while (a[i] + L < a[j]) j--;
    b[i][0] = j;
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < N; i++) {
      b[i][j] = b[b[i][j - 1]][j - 1];
    }
  }
}
int query(int x, int y) {
  int ret = 0;
  for (int i = 19; i >= 0; i--) {
    if (a[b[x][i]] < a[y]) {
      x = b[x][i];
      ret += 1 << i;
    }
  }
  return ret + 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  cin >> L;
  init();
  int Q, x, y;
  cin >> Q;
  while (Q--) {
    cin >> x >> y;
    x--, y--;
    if (x > y) swap(x, y);
    cout << query(x, y) << "\n";
  }
  return 0;
}
