#include <bits/stdc++.h>
using pii = std::pair<long long, long long>;
using namespace std;
const long long maxn = 1e5 + 5, maxlogn = 18;
long long n, l, q, x[maxn], a, b, r[maxlogn][maxlogn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> x[i];
  cin >> l;
  for (long long i = n - 1; i >= 0; i--) {
    long long pos = upper_bound(x, x + n, x[i] + l) - x - 1;
    r[0][i] = pos;
  }
  for (long long i = 1; i < maxlogn; i++)
    for (long long j = n - 1; j >= 0; j--) r[i][j] = r[i - 1][r[i - 1][j]];
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long j = maxlogn - 1; j >= 0; j--)
      if (r[j][a] < b) {
        a = r[j][a];
        ans += (1ll << j);
      }
    a = r[0][a];
    assert(a >= b);
    cout << ans + 1 << "\n";
  }
  return 0;
}
