#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template <typename T>
bool chmax(T &x, const T &y) {
  return (x < y) ? (x = y, true) : false;
};
template <typename T>
bool chmin(T &x, const T &y) {
  return (x > y) ? (x = y, true) : false;
};
int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < N; i++) cin >> x[i];
  int L;
  cin >> L;
  int next[N][20];
  for (int i = 0; i < N - 1; i++) {
    next[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
  }
  next[N - 1][0] = N;
  for (int j = 0; j < 19; j++) {
    for (int i = 0; i < N; i++) {
      if (next[i][j] == N)
        next[i][j + 1] = N;
      else
        next[i][j + 1] = next[next[i][j]][j];
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (u > v) swap(u, v);
    int ans = 0;
    for (int j = 19; j >= 0; j--) {
      if (next[u][j] <= v) u = next[u][j], ans |= (1 << j);
    }
    cout << ans << endl;
  }
}
