#include <bits/stdc++.h>
using lli = long long int;
using pii = std::pair<int, int>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
constexpr int K = 17;
constexpr int N = 1e5;
std::array<std::array<int, N>, K + 1> A;
std::array<int, N> X;
int main(void) {
  int n;
  scanf("%d", &n);
  for (int(i) = (0); (i) < (n); ++(i)) scanf("%d", &X[i]);
  int L;
  scanf("%d", &L);
  int l = 0, r = 1;
  while (l < n) {
    while (r < n and X[r] - X[l] <= L) r++;
    A[0][l] = r - 1;
    l++;
  }
  for (int(t) = (0); (t) < (K); ++(t))
    for (int(i) = (0); (i) < (n); ++(i)) A[t + 1][i] = A[t][A[t][i]];
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    if (a > b) std::swap(a, b);
    int res = 0;
    int ptr = a;
    while (ptr < b) {
      int cnt = 0;
      while (cnt + 1 <= K and A[cnt + 1][ptr] <= b) cnt++;
      res += (1 << cnt);
      ptr = A[cnt][ptr];
    }
    printf("%d\n", res);
  }
  return 0;
}
