#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T>>;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const long long MOD = 1e9 + 7;
int db[20][112345];
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int(i) = 0; (i) < (n); ++(i)) cin >> x[i];
  int len;
  cin >> len;
  int r = 0;
  for (int(l) = 0; (l) < (n); ++(l)) {
    while (r + 1 < n && x[r + 1] - x[l] <= len) ++r;
    db[l][0] = r;
  }
  for (int(i) = 0; (i) < (19); ++(i))
    for (int(j) = 0; (j) < (n); ++(j)) db[j][i + 1] = db[db[j][i]][i];
  int q;
  cin >> q;
  int a, b;
  while (q--) {
    cin >> a >> b;
    --a;
    --b;
    if (a > b) swap(a, b);
    int re = 0;
    for (int(i) = (20) - 1; (i) >= 0; --(i))
      if (db[a][i] < b) {
        a = db[a][i];
        re += 1 << i;
      }
    cout << re + 1 << endl;
  }
  return 0;
}
