#include <bits/stdc++.h>
using namespace std;
const long long MAX = 510000;
const long long MOD = 1000000007;
signed main() {
  long long n;
  cin >> n;
  long long x[n];
  for (long long i = 0; i < n; i++) cin >> x[i];
  long long r[20][n];
  long long l;
  cin >> l;
  long long m = 0;
  for (long long i = 0; i < n; i++) {
    while (m < n && x[m] - x[i] <= l) m++;
    r[0][i] = m - 1;
  }
  for (long long i = 1; i < 20; i++)
    for (long long j = 0; j < n; j++) r[i][j] = r[i - 1][r[i - 1][j]];
  long long q, a, b, ans;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    ans = 0;
    while (true) {
      long long j = 0;
      while (b > r[j][a]) j++;
      if (j == 0 || b == r[j][a]) {
        ans += (1 << j);
        break;
      }
      ans += (1 << (j - 1));
      a = r[j - 1][a];
    }
    cout << ans << endl;
  }
}
