#include <bits/stdc++.h>
using namespace std;
int n, L, q, x[100005], cha[100005], cha2[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
  scanf("%d", &L);
  int it = n;
  for (int i = n; i >= 1; i--) {
    while (x[it] - x[i] > L) it--;
    cha[i] = it;
  }
  for (int i = 1; i <= n; i++) cha2[i] = cha[cha[i]];
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b) {
      a = a + b;
      b = a - b;
      a = a - b;
    }
    int dem = 0, pos = a;
    while (cha2[pos] < b && cha2[pos] != cha[pos]) {
      pos = cha2[pos];
      dem += 2;
    }
    while (cha[pos] < b) {
      pos = cha[pos];
      dem++;
    }
    printf("%d\n", dem + 1);
  }
  return 0;
}
