#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 10;
int rec[MAX];
int tar[MAX];
int go(int x, int y) {
  int ret = 0;
  while (x < y) {
    x = tar[x];
    ret++;
  }
  return ret;
}
int main() {
  int n, l;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &rec[i]);
  }
  scanf("%d", &l);
  int ls = 0;
  for (int i = 1; i < n; i++) {
    while (rec[i] - rec[ls] > l) {
      tar[ls] = i - 1;
      ls++;
    }
  }
  for (int i = ls; i < n; i++) {
    tar[i] = n;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int p, s;
    scanf("%d %d", &p, &s);
    p--, s--;
    if (p > s) swap(p, s);
    printf("%d\n", go(p, s));
  }
  return 0;
}
