#include <bits/stdc++.h>
using namespace std;
long long n, arr[100050], l, q, a, b, p[100050][22];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = (long long)1; i <= (long long)n; i++) cin >> arr[i];
  cin >> l >> q;
  for (long long i = (long long)1; i <= (long long)n - 1; i++)
    p[i][0] = upper_bound(arr + 1, arr + n + 1, arr[i] + l) - arr - 1;
  p[n][0] = -1;
  for (long long k = (long long)1; k <= (long long)20; k++) {
    for (long long i = (long long)1; i <= (long long)n; i++) {
      if (p[i][k - 1] != -1)
        p[i][k] = p[p[i][k - 1]][k - 1];
      else
        p[i][k] = -1;
    }
  }
  while (q--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long k = 20; k >= 0; k--) {
      if (p[a][k] == -1) continue;
      if (p[a][k] <= b) {
        a = p[a][k];
        ans += (1 << k);
      }
    }
    cout << ans << "\n";
  }
}
