#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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<long long> x(n + 1);
  for (int i = int(0); i < int(n); ++i) cin >> x[i];
  x[n] = 1e18 + 1;
  int l;
  cin >> l;
  vector<vector<int>> db(16, vector<int>(n + 1, 0));
  for (int i = int(0); i < int(n); ++i) {
    int idx = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin();
    db[0][i] = --idx;
  }
  for (int i = int(0); i < int(16); ++i) db[i][n - 1] = db[i][n] = n;
  for (int i = int(1); i < int(16); ++i) {
    for (int j = int(0); j < int(n); ++j) {
      db[i][j] = db[i - 1][db[i - 1][j]];
    }
  }
  int q;
  cin >> q;
  for (int _ = int(0); _ < int(q); ++_) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    --a;
    --b;
    int ctr = 0;
    for (int i = 15; i >= 0; --i) {
      int p = db[i][a];
      if (p <= b) {
        a = p;
        ctr += (1 << i);
      }
    }
    cout << ctr << endl;
  }
}
