#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], cnt[maxn], c[24][maxn];
int n, l, q;
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    scanf("%d", &l);
    for (int i = 1; i < n; i++) {
      int tmp = cnt[i - 1];
      while (a[tmp] - a[i] <= l && tmp <= n) tmp++;
      cnt[i] = tmp - 1;
      c[0][i] = tmp - 1;
    }
    c[0][n] = 0;
    for (int i = 1; i <= 20; i++) {
      for (int j = 1; j <= n; j++) {
        c[i][j] = c[i - 1][c[i - 1][j]];
      }
    }
    scanf("%d", &q);
    while (q--) {
      int a, b, ans = 0;
      scanf("%d%d", &a, &b);
      if (a > b) swap(a, b);
      while (a < b) {
        int tmp = 0;
        for (tmp = 0; tmp <= 20; tmp++)
          if (c[tmp][a] >= b) break;
        if (tmp) tmp--;
        a = c[tmp][a];
        ans += 1 << tmp;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
