#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dp[100005][30];
int x[1000005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> x[i];
  int L;
  cin >> L;
  for (int i = 0; i < (int)(n); ++i) {
    dp[i][0] = (int)(upper_bound(x, x + n, x[i] + L) - x) - 1;
  }
  for (int j = 1; j <= 29; j++) {
    for (int i = 0; i < (int)(n); ++i) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int i = 29; i >= 0; i--) {
      if (dp[a][i] <= b) {
        ans += 1 << i;
        a = dp[a][i];
      }
    }
    cout << ans << endl;
  }
}
