#include <bits/stdc++.h>
using namespace std;
void Debug() { cout << '\n'; }
template <class FIRST, class... REST>
void Debug(FIRST arg, REST... rest) {
  cout << arg << " ";
  Debug(rest...);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  if (!v.empty()) {
    for (int i = int(0); i < int((int)(v).size() - 1); i++) out << v[i] << ", ";
    out << v.back();
  }
  out << "]";
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& v) {
  out << "(" << v.first << ", " << v.second << ")";
  return out;
}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const long long mod = 1000000007;
const int inf = 1 << 29;
const long long linf = 1LL << 60;
const double PI = 3.14159265358979323846;
int N;
long long A[MAX_N];
long long L;
int nex[20][MAX_N];
void solve() {
  cin >> N;
  for (int i = int(0); i < int(N); i++) cin >> A[i];
  cin >> L;
  int at = 0;
  for (int i = int(0); i < int(N); i++) {
    while (at < N && A[at] - A[i] <= L) at++;
    nex[0][i] = at - 1;
  }
  for (int i = int(0); i < int(19); i++) {
    for (int j = int(0); j < int(N); j++) {
      nex[i + 1][j] = nex[i][nex[i][j]];
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int res = 0, at = a;
    for (int i = 19; i >= 0; i--) {
      if (nex[i][at] <= b) {
        res |= (1 << i);
        at = nex[i][at];
      }
      if (at == b) break;
    }
    if (at < b) res += 1;
    cout << res << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed;
  cout.precision(20);
  srand((unsigned int)time(NULL));
  solve();
  return 0;
}
