#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int s[maxn], n, L, Q;
int cnt[maxn], c[36][maxn];
int main() {
  s[0] = 0;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
    scanf("%d", &L);
    for (int i = 1; i < n; i++) {
      int tmp = cnt[i - 1];
      while (s[tmp] - s[i] <= L && tmp <= n) tmp++;
      cnt[i] = tmp - 1;
      c[0][i] = tmp - 1;
    }
    c[0][n] = n;
    for (int i = 1; i < 25; 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);
      int tmp = a, sum = 0;
      while (a < b) {
        int ss = 0;
        for (ss = 0; ss < 25; ss++) {
          if (c[ss][a] >= b) break;
        }
        if (ss > 0) ss--;
        a = c[ss][a];
        ans += 1 << ss;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
