#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N = 100005;
int x[N], nxt[N];
int main() {
  register int n, l, q, a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &l);
  for (int i = 1, j = 1; i <= n; i++) {
    while (x[j + 1] - x[i] <= l && j <= n) j++;
    nxt[i] = j;
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int sum = 0;
    while (a < b) {
      sum++;
      a = nxt[a];
    }
    printf("%d\n", sum);
  }
  return 0;
}
