#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using P = pair<ll, ll>;
using grid = vector<vector<int>>;
const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1 << 30;
const ll mod = 998244353LL;
ll N, L, Q;
vector<ll> x;
ll rnex[30][100005];
int main() {
  cin >> N;
  x.resize(N);
  for (int i = 0; i < (int)(N); i++) cin >> x[i];
  cin >> L;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(30); j++) {
      rnex[j][i] = INF;
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    if (i != N - 1) {
      auto rite = upper_bound(x.begin(), x.end(), x[i] + L);
      rnex[0][i] = rite - x.begin() - 1;
    }
  }
  for (int i = 0; i < (int)(29); i++) {
    for (int j = 0; j < (int)(N); j++) {
      if (rnex[i][j] != INF) rnex[i + 1][j] = rnex[i][rnex[i][j]];
    }
  }
  cin >> Q;
  for (int i = 0; i < (int)(Q); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int s = min(a, b);
    int t = max(a, b);
    int l = 0, r = N;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      int L = s;
      for (int i = 0; i < (int)(30); i++) {
        if (mid & (1 << i)) {
          L = rnex[i][L];
        }
      }
      if (L < t)
        l = mid;
      else
        r = mid;
    }
    cout << r << endl;
  }
}
