#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 reach(31, vll(n));
  for (int i = 0; i < n; i++) {
    ll nxt = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1;
    reach[0][i] = nxt;
  }
  for (int k = 0; k < 30; k++) {
    for (int i = 0; i < n; i++) {
      reach[k + 1][i] = reach[k][reach[k][i]];
    }
  }
  ll q;
  cin >> q;
  ll a, b;
  while (q) {
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    ll res = 0;
    while (a < b) {
      for (int k = 0; k < 25; k++) {
        if (b < reach[k + 1][a]) {
          res += (1 << k);
          a = reach[k][a];
          break;
        }
      }
    }
    cout << res << endl;
    q--;
  }
  return 0;
}
