#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 = 19; i >= 0; i--) {
    if (mx[x][i] <= y) {
      x = mx[x][i];
      ans += (1 << i);
    }
  }
  if (x < y) ans++;
  return ans;
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  cin >> len;
  for (long long i = 1; i <= n; i++) {
    mx[i][0] = lower_bound(a + 1, a + 1 + n, a[i] + len + 1) - (a + 1);
  }
  for (long long j = 1; j <= 20; j++) {
    for (long long i = 1; i <= n; i++) {
      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';
  }
}
