#include <bits/stdc++.h>
using namespace std;
int x[100010], fa[100010];
int main() {
  int n, L, q, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &L);
  int l = 1, r = 1;
  while (l < n) {
    while (r <= n && x[r] - x[l] <= L) r++;
    fa[l] = r - 1;
    l++;
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &a, &b);
    int ans = 0;
    if (a > b) swap(a, b);
    while (fa[a] < b) {
      ans++;
      a = fa[a];
    }
    printf("%d\n", ans + 1);
  }
}
