#include <bits/stdc++.h>
using namespace std;
void _dbg(string) { cout << endl; }
template <class H, class... T>
void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> vec[i];
  int L;
  cin >> L;
  vector<vector<int>> dp(14, vector<int>(n));
  int p = 0;
  for (int i = (int)(0); i < (int)(n); i++) {
    while (p + 1 < n && vec[p + 1] - vec[i] <= L) p++;
    dp[0][i] = p;
  }
  for (int i = (int)(1); i < (int)(14); i++) {
    for (int j = (int)(0); j < (int)(n); j++)
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
  }
  int q;
  cin >> q;
  for (int _ = (int)(0); _ < (int)(q); _++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int l = 0, r = n;
    while (r - l > 1) {
      int m = (r + l) / 2;
      auto ok = [&]() {
        int pos = a;
        int x = m;
        int c = 0;
        while (x > 0) {
          if (x & 1) pos = dp[c][pos];
          c++;
          x /= 2;
        }
        return pos >= b;
      };
      if (ok())
        r = m;
      else
        l = m;
    }
    cout << r << endl;
  }
  return 0;
}
