#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll inf = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vll x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  ll l;
  cin >> l;
  vvll g(n);
  for (int i = 0; i < n - 1; i++) {
    ll id = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1;
    g[i].push_back(id);
    g[id].push_back(i);
  }
  vll d(n, inf), used(n);
  ll s = n - 1;
  queue<ll> que;
  que.push(s);
  d[s] = 0;
  used[s] = 1;
  while (!que.empty()) {
    ll cur = que.front();
    que.pop();
    used[cur] = 1;
    for (auto nxt : g[cur]) {
      if (used[nxt]) continue;
      d[nxt] = d[cur] + 1;
      que.push(nxt);
    }
  }
  ll q;
  cin >> q;
  ll a, b;
  while (q) {
    cin >> a >> b;
    a--, b--;
    ll res = abs(d[a] - d[b]);
    if (res == 0)
      cout << 1 << endl;
    else
      cout << res << endl;
    q--;
  }
  return 0;
}
