#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct edge {
  long long to, cost, val;
};
template <class T, class U>
bool chmin(T& a, const U& b) {
  if (a <= b) return false;
  a = b;
  return true;
}
template <class T, class U>
bool chmax(T& a, const U& b) {
  if (a >= b) return false;
  a = b;
  return true;
}
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, -1, 1};
struct Doubling {
  vector<vector<int> > table;
  const int LOG;
  const int size;
  Doubling(int sz, long long lim_t)
      : LOG(64 - __builtin_clzll(lim_t)), size(sz) {
    table.resize(LOG, vector<int>(sz, -1));
  }
  void set_next(int k, int x) { table[0][k] = x; }
  void build() {
    for (int k = 0; k + 1 < LOG; k++) {
      for (int i = 0; i < size; i++) {
        if (table[k][i] == -1)
          table[k + 1][i] = -1;
        else
          table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }
  int query(int k, long long t) {
    for (int i = LOG - 1; i >= 0; i--) {
      if (((t >> i) & 1)) k = table[i][k];
    }
    return k;
  }
};
signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  long long L;
  cin >> L;
  Doubling db(N, N);
  x.push_back(1LL << 61);
  for (int i = 0; i < N; i++) {
    auto t = (int)(lower_bound(x.begin(), x.end(), x[i] + L + 1) - x.begin());
    int next = t - 1;
    if (next == i) next++;
    db.set_next(i, next);
  }
  db.build();
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    int ok = N, ng = 0;
    while (ok - ng != 1) {
      int mid = (ok + ng) / 2;
      if (db.query(a, mid) >= b)
        ok = mid;
      else
        ng = mid;
    }
    cout << ok << endl;
  }
}
