#include <bits/stdc++.h>
using namespace std;
long long f[10005][25];
long long arr[10005];
int main() {
  long long n, l, a, b, q;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  cin >> l;
  for (int i = 1; i <= n; i++) {
    long long k = upper_bound(arr + 1, arr + n + 1, arr[i] + l) - arr;
    k = k - 1;
    if (arr[i] + l >= arr[n]) {
      f[i][0] = n;
    } else {
      f[i][0] = k;
    }
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n; i++) {
      f[i][j] = f[f[i][j - 1]][j - 1];
    }
  }
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    long long ans = 0;
    for (int i = 20; i >= 0; i--) {
      if (f[a][i] < b) {
        ans += (1 << i);
        a = f[a][i];
      }
    }
    cout << ans + 1 << endl;
  }
}
