#include <bits/stdc++.h>
using namespace std;
const long long N = 1000030;
const long long mod = 1e9 + 7;
long long n, l;
long long arr[N], dp[22][N];
long long q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> arr[i];
  cin >> l;
  for (int i = 0; i < n; i++) {
    dp[0][i] = upper_bound(arr, arr + n, l + arr[i]) - arr - 1;
  }
  for (__typeof(21) k = (1) - ((1) > (21)); k != (21) - ((1) > (21));
       k += 1 - 2 * ((1) > (21))) {
    for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
         i += 1 - 2 * ((0) > (n)))
      dp[k][i] = dp[k - 1][dp[k - 1][i]];
  }
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    long long ans = 0;
    if (a > b) swap(a, b);
    for (int k = 20; k >= 0; k--) {
      if (dp[k][a] <= b) {
        ans += 1 << k;
        a = dp[k][a];
      }
    }
    cout << ans << "\n";
  }
}
