#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> x;
long long l;
long long q;
unordered_map<long long, unordered_map<long long, long long>> dp;
long long ub;
int main() {
  cin >> n;
  x = vector<long long>(n + 1);
  for (long long i = 1; i <= n; i++) cin >> x[i];
  cin >> l;
  for (long long i = 1; i <= n + 1; i++) dp[0][i] = i;
  for (long long i = 1; i <= n; i++)
    dp[1][i] = upper_bound(x.begin(), x.end(), x[i] + l) - x.begin() - 1;
  dp[1][n + 1] = n + 1;
  for (long long b = 2; b < n; b <<= 1) {
    ub = b;
    for (long long i = 1; i <= n + 1; i++)
      dp[b][i] = dp[(b >> 1)][dp[(b >> 1)][i]];
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (long long bit = ub; bit > 0; bit >>= 1) {
      if (dp[bit][dp[ans][a]] < b) ans ^= bit;
    }
    ans++;
    cout << ans << endl;
  }
  return 0;
}
