#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
const long long MAXN = 32005, K = 200043, M = 1000043, INF = 1e18 + 7;
const long double PI = acos(-1.0);
long long MOD = 1e9 + 7;
template <class T>
T sqr(T a) {
  return a * a;
}
long long mul(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
long long sum(long long a, long long b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}
long long sub(long long a, long long b) { return sum(a, MOD - b); }
long long bin_pow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = mul(res, a);
    a = mul(a, a);
    n >>= 1;
  }
  return res;
}
void solve() {
  int n, q;
  long long L;
  cin >> n;
  vector<long long> x(n), pref(n + 1);
  for (int i = 0; i < n; ++i) cin >> x[i];
  cin >> L;
  sort(x.begin(), x.end());
  long long i = 0, st = x[0];
  while (i < n - 1) {
    if (i != 0) pref[i] = pref[i - 1] + 1;
    st = x[i];
    long long j = i + 1;
    while (x[j] - st <= L) {
      pref[j] = pref[i] + 1;
      ++j;
    }
    i = j;
  }
  cin >> q;
  while (q-- > 0) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    if (l > r) swap(l, r);
    long long ans = pref[r] - pref[l] + (pref[l + 1] == pref[l]);
    cout << ans << '\n';
    ;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t-- > 0) solve();
  return 0;
}
