#include <bits/stdc++.h>
using namespace std;
int n, l, q;
int a[100005];
int rig[100005];
int fa[18][100005];
int ln = 17;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &l);
  int j = 1;
  for (i = 1; i <= n; i++) {
    if (j <= i) j = i;
    while (1) {
      if (j > n) break;
      if (a[j] > a[i] + l) break;
      j++;
    }
    rig[i] = j - 1;
    fa[0][i] = j - 1;
  }
  for (i = 1; i <= ln; i++) {
    for (j = 1; j <= n; j++) {
      fa[i][j] = fa[i - 1][fa[i - 1][j]];
    }
  }
  scanf("%d", &q);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    int ans = 0;
    while (1) {
      if (x == y) break;
      for (i = 0;; i++) {
        j = fa[i][x];
        if (j >= y) break;
      }
      if (j > y) i--;
      ans += (1 << i);
      x = fa[i][x];
    }
    printf("%d\n", ans);
  }
  return 0;
}
