#include <bits/stdc++.h>
using namespace std;
int hotel[100005];
int reach[100005];
int main() {
  int n, L, Q;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &hotel[i]);
    scanf("%d", &L);
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int dis = hotel[j] - hotel[i];
        if (dis <= L) {
          reach[i] = j;
        }
      }
    }
    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;
}
