#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> dp(20, vector<int>(n, 0));
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  int l;
  cin >> l;
  for (size_t i = 0; i < n; i++) {
    auto itr = lower_bound((a).begin(), (a).end(), a[i] + l + 1) - a.begin();
    dp[0][i] = itr - 1;
    cout << dp[0][i] << endl;
  }
  for (int k = 0; k < 19; k++) {
    for (int i = 0; i < n; i++) {
      dp[k + 1][i] = dp[k][dp[k][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (x > y) {
      swap(x, y);
    }
    int day = 0;
    for (int i = 19; i >= 0; i--) {
      if (dp[i][x] < y) {
        x = dp[i][x];
        day += 1 << i;
      }
    }
    cout << day + 1 << endl;
  }
}
