#include <bits/stdc++.h>
using namespace std;
long long N, L, Q, x[100005];
vector<long long> G[100005], X;
map<long long, long long> mp;
long long d[100005];
signed main() {
  cin >> N;
  for (long long i = 0; i < N; i++) {
    cin >> x[i];
    mp[x[i]] = i;
    X.push_back(-x[i]);
    d[i] = 1000000009;
    if (i < N - 1) {
      G[i].push_back(i + 1);
    }
  }
  sort(X.begin(), X.end());
  cin >> L;
  for (long long i = 0; i < N - 1; i++) {
    G[i].push_back(mp[-*lower_bound(X.begin(), X.end(), -x[i] - L)]);
  }
  queue<long long> que;
  que.push(0ll);
  d[0] = 0ll;
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    for (long long i = 0; i < (long long)G[v].size(); i++) {
      long long to = G[v][i];
      if (d[to] == 1000000009) {
        que.push(to);
        d[to] = d[v] + 1ll;
      }
    }
  }
  for (long long i = N - 2; i >= 0; i--) {
    if (d[i + 1] < d[i]) {
      d[i] = d[i + 1];
    }
  }
  cin >> Q;
  for (long long i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a < b) swap(a, b);
    cout << max(d[a] - d[b], 1ll) << endl;
  }
  return 0;
}
