#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline ostream& operator<<(ostream& os, vector<T> arr) {
  os << "[";
  for (int i = 0; i < (int)arr.size(); i++)
    os << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");
  os << endl;
  return os;
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int D = 30;
const int MAX_N = 100000;
int n, l;
vector<int> x;
vector<vector<int>> tor;
void ftor() {
  for (int i = 0; i < n; i++) {
    int L = i + 1, R = n;
    while (R - L > 1) {
      int mid = (L + R) / 2;
      (x[mid] - x[i] <= l ? L : R) = mid;
    }
    tor[0][i] = L;
  }
  tor[0][n - 1] = n - 1;
  for (int i = 0; i < D - 1; i++) {
    for (int j = 0; j < n; j++) {
      tor[i + 1][j] = tor[i][tor[i][j]];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < D; j++) {
      if (tor[j][i] == n - 1) {
        for (j++; j < D; j++) tor[j][i] = n;
      }
    }
  }
}
int main() {
  cin >> n;
  x.resize(n), tor.resize(D, vector<int>(n));
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l;
  ftor();
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) {
      swap(a, b);
    }
    int num = 0;
    for (int i = D - 1; i >= 0; i--) {
      if (tor[i][a] <= b) {
        a = tor[i][a];
        num += (1 << i);
      }
    }
    cout << num << endl;
  }
}
