#include <bits/stdc++.h>
long long powz(long long v, long long k) {
  long long r(1), t(v);
  while (k) {
    if (k & 1) r *= t;
    t *= t;
    k >>= 1;
  }
  return r;
}
signed main() {
  long long n;
  std::cin >> n;
  std::vector<long long> x(n);
  for (long long i = 0; i < (n); i++) std::cin >> x[i];
  long long L;
  std::cin >> L;
  std::vector<long long> ltor(n);
  {
    long long r;
    r = 0;
    for (long long l = 0; l < n; l++) {
      while (r < n && x[r] - x[l] <= L) r++;
      ltor[l] = r - 1;
    }
  }
  std::vector<std::vector<long long> > ltord(20, std::vector<long long>(n));
  ltord[0] = ltor;
  for (long long d = 0; d < 19; d++) {
    for (long long i = 0; i < (n); i++) ltord[d + 1][i] = ltord[d][ltord[d][i]];
  }
  std::reverse((x).begin(), (x).end());
  std::vector<long long> rtol(n);
  {
    long long r;
    r = 0;
    for (long long l = 0; l < n; l++) {
      while (r < n && x[l] - x[r] <= L) r++;
      rtol[l] = r - 1;
    }
  }
  std::vector<std::vector<long long> > rtold(20, std::vector<long long>(n));
  rtold[0] = rtol;
  for (long long d = 0; d < 19; d++) {
    for (long long i = 0; i < (n); i++) rtold[d + 1][i] = rtold[d][rtold[d][i]];
  }
  long long q;
  std::cin >> q;
  for (long long z = 0; z < (q); z++) {
    long long a, b;
    std::cin >> a >> b;
    a--;
    b--;
    if (a > b) {
      a = n - 1 - a;
      b = n - 1 - b;
      long long days = 0;
      long long current = a;
      while (current != b) {
        long long minv = 20;
        for (long long v = 19; v >= 0; v--) {
          if (ltord[v][current] <= b) {
            minv = v;
            if (b != n - 1) break;
          }
        }
        if (minv == 20) {
          days += 1;
          current = b;
        } else {
          days += powz(2, minv);
          current = ltord[minv][current];
        }
      }
      std::cout << (days) << '\n';
    } else {
      long long days = 0;
      long long current = a;
      while (current != b) {
        long long minv = 20;
        for (long long v = 19; v >= 0; v--) {
          if (ltord[v][current] <= b) {
            minv = v;
            if (b != n - 1) break;
          }
        }
        if (minv == 20) {
          days += 1;
          current = b;
        } else {
          days += powz(2, minv);
          current = ltord[minv][current];
        }
      }
      std::cout << (days) << '\n';
    }
  }
  return 0;
}
