#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
int n, L;
int ar[100005];
int nxt[20][100005];
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> ar[i];
  cin >> L;
  for (int i = 0; i < (n); ++i) {
    nxt[0][i] = upper_bound(ar, ar + n, ar[i] + L) - ar;
    --nxt[0][i];
  }
  nxt[0][n] = n;
  for (int j = 0; j < (19); ++j)
    for (int i = 0; i < (n); ++i) {
      nxt[j + 1][i] = nxt[j][nxt[j][i]];
    }
  int q;
  cin >> q;
  for (int _ = 0; _ < (q); ++_) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    int res = 0;
    if (a > b) swap(a, b);
    for (int i = 19; i >= 0; --i)
      if (nxt[i][a] <= b) {
        a = nxt[i][a];
        res += (1 << i);
      }
    if (a < b) ++res;
    cout << res << endl;
  }
  return 0;
}
