#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 4;
vector<long long> v;
long long a[N];
long long mx[N][25];
long long len;
long long n;
long long jump(long long x, long long y) {
  long long ans = 0;
  for (long long i = 20; i >= 0; i--) {
    if (mx[x][i] <= y) {
      x = mx[x][i];
      ans += (1 << i);
    }
  }
  if (x < y) ans++;
  return ans;
}
signed main() {
  for (long long j = 0; j < 25; j++) {
    for (long long i = 0; i < N; i++) {
      mx[i][j] = N - 1;
    }
  }
  cin >> n;
  v.push_back(-1);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    v.push_back(a[i]);
  }
  cin >> len;
  for (long long i = 1; i < (long long)v.size(); i++) {
    long long pos = upper_bound(v.begin(), v.end(), v[i] + len) - v.begin() - 1;
    mx[i][0] = pos;
  }
  for (long long j = 1; (1 << j) <= n; j++) {
    for (long long i = 1; i + (1 << j) - 1 <= n; j++) {
      if (mx[i][j - 1] != N - 1) mx[i][j] = mx[mx[i][j - 1]][j - 1];
    }
  }
  long long q;
  cin >> q;
  while (q--) {
    long long i, j;
    scanf("%lld %lld", &i, &j);
    if (i > j) swap(i, j);
    cout << jump(i, j) << '\n';
  }
}
