#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T itr1, T itr2) {
  auto now = itr1;
  while (now < itr2) {
    cout << *now << " ";
    now++;
  }
  cout << endl;
}
const long long MOD = pow(10, 9) + 7;
const long long LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;
vector<long long> fac;
void c_fac(int x = pow(10, 6) + 10) {
  fac.resize(x, true);
  for (int i = (int)0; i < (int)x; i++) fac[i] = i ? (fac[i - 1] * i) % MOD : 1;
}
long long inv(long long a, long long m = MOD) {
  long long b = m, x = 1, y = 0;
  while (b != 0) {
    int d = a / b;
    a -= b * d;
    swap(a, b);
    x -= y * d;
    swap(x, y);
  }
  return (x + m) % m;
}
long long nck(long long n, long long k) {
  return fac[n] * inv(fac[k] * fac[n - k] % MOD) % MOD;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
vector<vector<int>> cp, cm;
vector<int> dp, dm;
void dfs(int n, vector<int> &d, vector<vector<int>> c) {
  for (auto x : c[n]) {
    d[x] = d[n] + 1;
    dfs(x, d, c);
  }
}
int main() {
  int N;
  cin >> N;
  int x[N];
  for (int i = (int)0; i < (int)N; i++) cin >> x[i];
  int L;
  cin >> L;
  cp.resize(N);
  for (int i = (int)0; i < (int)N - 1; i++) {
    int pos = (upper_bound(x, x + N, x[i] + L) - 1) - x;
    cp[pos].push_back(i);
  }
  cm.resize(N);
  for (int i = N - 1; i > 0; i--) {
    int pos = lower_bound(x, x + N, x[i] - L) - x;
    cm[pos].push_back(i);
  }
  dp.resize(N, 0);
  dfs(N - 1, dp, cp);
  dm.resize(N, 0);
  dfs(0, dm, cm);
  debug(dp.begin(), dp.end());
  debug(dm.begin(), dm.end());
  int Q;
  cin >> Q;
  for (int i = (int)0; i < (int)Q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int result = a > b ? dm[a] - dm[b] : dp[a] - dp[b];
    cout << result << endl;
  }
  return 0;
}
