#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e16;
const long double EPS = 1e-10;
const long double PI = 3.141592653589793;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const pair<long long, long long> fd[] = {make_pair(1, 0), make_pair(-1, 0),
                                         make_pair(0, 1), make_pair(0, -1)};
long long n, l, q, x[110000];
pair<long long, long long> qr[110000];
long long d[20][110000];
signed main() {
  cin >> n;
  for (long long i = (0); i < (n); i++) cin >> x[i];
  cin >> l >> q;
  for (long long i = (0); i < (q); i++) cin >> qr[i].first >> qr[i].second;
  for (long long i = (0); i < (20); i++)
    for (long long j = (0); j < (110000); j++) d[i][j] = INF;
  for (long long i = (0); i < (n); i++) {
    auto itr = upper_bound(x + i, x + n, x[i] + l) - 1;
    d[0][i] = itr - x;
  }
  long long k = 0, kk = 1;
  while (kk <= n) {
    for (long long i = (0); i < (n); i++) {
      d[k + 1][i] = d[k][d[k][i]];
    }
    k++;
    kk *= 2;
  }
  for (long long i = (0); i < (q); i++) {
    long long a = qr[i].first, b = qr[i].second;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long ans = 0, now = a;
    while (now < b) {
      long long ok = 0, ng = 20;
      while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (d[mid][now] <= b)
          ok = mid;
        else
          ng = mid;
      }
      now = d[ok][now];
      ans += (long long)pow(2, ok);
    }
    cout << ans << endl;
  }
}
