#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
long long qpow(long long x, long long y, long long MOD) {
  long long a = 1;
  while (y) {
    if (y & 1) a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}
int r[N][20], x[N], n, L, Q, dep;
void init() {
  for (int i = int(1); i <= int(n); ++i)
    r[i][0] = upper_bound(x + i, x + n + 1, x[i] + L) - x - 1;
  dep = 1;
  while (dep < n) dep <<= 1;
  for (int d = int(1); d <= int(dep); ++d) {
    for (int i = int(1); i <= int(n); ++i) {
      r[i][d] = r[r[i][d - 1]][d - 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = int(1); i <= int(n); ++i) cin >> x[i];
  cin >> L >> Q;
  init();
  while (Q--) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    int ans = 0;
    while (u < v) {
      int L = 0, R = dep, p = 0;
      while (L <= R) {
        int mid = (L + R) >> 1;
        int to = r[u][mid];
        if (x[to] >= x[v]) {
          p = mid;
          R = mid - 1;
        } else
          L = mid + 1;
      }
      u = r[u][p];
      ans += (1 << p);
    }
    cout << ans << '\n';
  }
  return 0;
}
