#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
constexpr int N_MAX = 100000;
constexpr int N_LOG_MAX = 4;
constexpr int X_MAX = 1000000001;
int n, l, q;
vector<ll> hotels(N_MAX, X_MAX);
vector<vector<ll>> nxt(N_MAX, vector<ll>(N_LOG_MAX, N_MAX));
int solve(int a, int b) {
  int ng = 0, ok = n;
  while (ok - ng > 1) {
    int mid = (ng + ok) / 2;
    int c = a;
    for (int j = N_LOG_MAX - 1; j >= 0 && c < b; --j) {
      if (mid & (1 << j)) {
        c = nxt[c][j];
      }
    }
    if (b <= c) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> hotels[i];
  }
  cin >> l;
  for (int i = 0; i < n; ++i) {
    auto itr = upper_bound(hotels.begin(), hotels.end(), hotels[i] + l);
    nxt[i][0] = int(itr - hotels.begin()) - 1;
  }
  for (int j = 1; j < N_LOG_MAX; ++j) {
    for (int i = 0; i < n; ++i) {
      if (nxt[i][j - 1] < n) {
        nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
      }
    }
  }
  cin >> q;
  int a, b;
  for (int i = 0; i < q; ++i) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    cout << solve(a - 1, b - 1) << endl;
  }
}
