#include <bits/stdc++.h>
using namespace std;
int hotel[100005];
int reach[100005];
int main() {
  int n, L, Q;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &hotel[i]);
  scanf("%d", &L);
  for (int i = 1; i < n; i++) {
    int l = i, r = n;
    while (l <= r) {
      int mid = (l + r) >> 1;
      int dis = hotel[mid] - hotel[i];
      if (dis <= L) {
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    reach[i] = r;
  }
  scanf("%d", &Q);
  while (Q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int day = 0;
    int now = a;
    while (1) {
      if (reach[now] >= b) {
        day++;
        break;
      } else {
        now = reach[now];
        day++;
      }
    }
    printf("%d\n", day);
  }
  return 0;
}
