#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string cts(char x) {
  string second(1, x);
  return second;
}
const long long MOD = 1e9 + 7;
template <typename T>
void maxself(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void minself(T& a, T b) {
  a = min(a, b);
}
long long A[(long long)1e5 + 5];
const long long sqn = 400;
long long cnt[sqn + 5][sqn + 5], nxt[sqn + 5][sqn + 5], id[sqn + 5][sqn + 5];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = (0); i <= (long long)(n - 1); ++i) cin >> A[i];
  long long L;
  cin >> L;
  cnt[(n - 1) % sqn][(n - 1) / sqn] = 1;
  nxt[(n - 1) % sqn][(n - 1) / sqn] = id[(n - 1) % sqn][(n - 1) / sqn] = n + 1;
  for (long long i = (n - 2); i >= (long long)(0); --i) {
    long long tgt = prev(upper_bound(A, A + n, A[i] + L)) - A;
    if (i / sqn == tgt / sqn) {
      cnt[i % sqn][i / sqn] = cnt[tgt % sqn][tgt / sqn] + 1;
      nxt[i % sqn][i / sqn] = tgt;
      id[i % sqn][i / sqn] = id[tgt % sqn][tgt / sqn];
    } else {
      cnt[i % sqn][i / sqn] = 1;
      nxt[i % sqn][i / sqn] = id[i % sqn][i / sqn] = tgt;
    }
  }
  for (long long i = (0); i <= (long long)(n - 1); ++i) {
  }
  long long Q;
  cin >> Q;
  while (Q--) {
    long long a, b;
    cin >> a >> b;
    --a, --b;
    if (a > b) swap(a, b);
    long long day = 0;
    long long idx = a;
    for (long long i = (a / sqn); i <= (long long)(b / sqn); ++i) {
      if (idx >= b) break;
      if (0)
        cout << "idx"
             << "=" << idx << " , "
             << "day"
             << "=" << day << endl;
      if ((i + 1) * sqn - 1 > b) {
        while (idx < b) {
          ++day;
          idx = nxt[idx % sqn][idx / sqn];
        }
      } else {
        day += cnt[idx % sqn][idx / sqn];
        idx = id[idx % sqn][idx / sqn];
        if (idx >= b) break;
      }
    }
    cout << day << '\n';
  }
}
