#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, x[N];
int L, Q, a[N], b[N];
int nex[N][22];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%d", &L);
  x[n + 1] = 2e9 + 7;
  for (int i = 1; i <= n; i++) {
    int pos = upper_bound(x + 1, x + 2 + n, x[i] + L) - x - 1;
    nex[i][0] = pos;
  }
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      nex[j][i] = nex[nex[j][i - 1]][i - 1];
    }
  }
  scanf("%d", &Q);
  for (int q = 1; q <= Q; q++) {
    scanf("%d %d", &a[q], &b[q]);
    if (a[q] > b[q]) swap(a[q], b[q]);
    int ans = 0;
    for (int i = 19; i >= 0; i--) {
      if (nex[a[q]][i] < b[q]) {
        ans += (1 << i);
        a[q] = nex[a[q]][i];
      }
    }
    for (int i = 0; i <= 19; i++) {
      if (nex[a[q]][i] == b[q]) {
        ans += 1 << i;
        break;
      }
    }
    printf("%d\n", ans);
  }
}
