#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline void chkmax(T &x, const T2 &y) {
  if (x < y) x = y;
}
template <class T, class T2>
inline void chkmin(T &x, const T2 &y) {
  if (x > y) x = y;
}
const int MAXN = (1 << 20);
int n, l;
int x[MAXN];
void read() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l;
}
int nxt[MAXN][20];
void solve() {
  x[n] = (int)2e9 + 42;
  for (int i = 0; i < 20; i++) nxt[n][0] = n;
  for (int i = n - 1; i >= 0; i--) {
    nxt[i][0] = nxt[i + 1][0];
    while (x[nxt[i][0]] - x[i] > l) nxt[i][0]--;
    for (int l = 1; l < 20; l++) nxt[i][l] = nxt[nxt[i][l - 1]][l - 1];
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int answer = (a == b) ? -1 : 0;
    for (int l = 19; l >= 0; l--)
      if (x[nxt[a][l]] < x[b]) answer += (1 << l), a = nxt[a][l];
    cout << answer + 1 << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
