#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long INF = 1e18;
const long long M = 1e9 + 7;
const long long maxn = 5e5;
long long dp[maxn][20];
long long x[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> x[i];
  }
  long long l;
  cin >> l;
  for (long long i = 0; i < n; ++i) {
    dp[i][0] = upper_bound(x, x + n, x[i] + l) - x - 1;
  }
  dp[n - 1][0] = n;
  long long m = 0;
  for (long long j = 1; (1 << j) < n; ++j, ++m) {
    for (long long i = 0; i < n; ++i) {
      if (i + (1 << j) >= n) dp[i][j] = n;
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long l, r;
    cin >> l >> r;
    --l, --r;
    if (l > r) swap(l, r);
    long long res = 0;
    while (1) {
      long long time = lower_bound(dp[l], dp[l] + m, r) - dp[l];
      if (time == 0) {
        ++res;
        break;
      } else {
        time--;
        res += 1 << time;
        l = dp[l][time];
      }
    }
    cout << res << endl;
  }
  return 0;
}
