#include <bits/stdc++.h>
using namespace std;
long long N, x[100000], L;
int nx[100000][20];
int Q;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L;
  int r = 0;
  for (int l = 0; l < N; l++) {
    while (r < N && x[r] - x[l] <= L) {
      r++;
    }
    nx[l][0] = r - 1;
  }
  for (int i = 0; i < N; i++) {
  }
  for (int k = 1; k < 20; k++) {
    for (int i = 0; i < N; i++) {
      nx[i][k] = nx[nx[i][k - 1]][k - 1];
    }
  }
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      int tmp = a;
      a = b;
      b = tmp;
    }
    int cnt = 0;
    for (int k = 19; k >= 0; k--) {
      if (nx[a][k] <= b) {
        a = nx[a][k];
        cnt += (1 << k);
      }
    }
    cout << cnt << endl;
  }
}
