#include <bits/stdc++.h>
using namespace std;
int n, L, q, x[100005], cha[100005][30];
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][0] = it;
  }
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++)
      if (cha[cha[i][j - 1]][j - 1] != cha[i][j - 1])
        cha[i][j] = cha[cha[i][j - 1]][j - 1];
  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;
    int lg = 0;
    while ((1 << lg) <= b - a) lg++;
    lg--;
    for (int i = lg; i >= 0; i--) {
      if (cha[pos][i] < b) {
        pos = cha[pos][i];
        dem += (1 << i);
      }
    }
    printf("%d\n", dem + 1);
  }
  return 0;
}
