#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
void solve();
clock_t start_time;
double get_current_time() {
  return (double)(clock() - start_time) / CLOCKS_PER_SEC;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
}
const int limit = 100500;
const int k = 18;
const int inf = 10050000;
int n, l;
int x[limit];
int dp[limit][k + 1];
void precalc() {
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (j < n && x[j] - x[i] <= l) {
      ++j;
    }
    dp[i][1] = j - i - 1;
  }
  for (int j = 2; j <= k; j++) {
    for (int i = 0; i + (1 << j) <= n; i++) {
      dp[i][j] = dp[i][j - 1] + dp[i + (1 << (j - 1))][j - 1];
    }
  }
}
bool check(int l, int r, int x) {
  for (int j = k; j > 0 && x >= 0; j--) {
    if (dp[l][j] && x - (1 << (j - 1)) >= 0) {
      x -= (1 << (j - 1));
      l += dp[l][j];
    }
  }
  return l >= r && x >= 0;
}
int calc(int reql, int reqr) {
  int l = 0, r = n + 1;
  while (r > l + 1) {
    int mid = (r + l) / 2;
    if (check(reql, reqr, mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return r;
}
void solve() {
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> x[i];
  }
  cin >> l;
  precalc();
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r, --l, --r;
    if (l > r) swap(l, r);
    cout << calc(l, r) << '\n';
  }
}
