#include <bits/stdc++.h>
using namespace std;
long long n, l, q, a, b, ans, x[(100009)], f[(100009)][21];
int main() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> x[i];
  cin >> l >> q;
  for (long long i = 1; i <= n; ++i) {
    long long pos = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
    f[i][0] = pos;
  }
  for (long long i = 1; i <= 20; ++i)
    for (long long j = 1; j <= n; ++j) f[j][i] = f[f[j][i - 1]][i - 1];
  for (long long i = 1; i <= q; ++i) {
    cin >> a >> b;
    ans = 0;
    if (a > b) swap(a, b);
    for (long long i = 20; i >= 0; --i)
      if (x[f[a][i]] <= x[b]) a = f[a][i], ans += 1 << i;
    cout << ans << endl;
  }
}
