#include <bits/stdc++.h>
template <class T>
void chmax(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, const T& b) {
  a = min(a, b);
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
const int mod = 1e9 + 7, INF = 1 << 30;
const double EPS = 1e-12, PI = 3.1415926535897932384626;
const ll lmod = 1e9 + 7, LINF = 1LL << 60;
const int MAX_N = 100005;
ll N, L, x[MAX_N];
int r[MAX_N][20];
void prepare() {
  for (int i = 0; i < N; i++)
    r[i][0] = int(upper_bound(x, x + N, x[i] + L) - x) - 1;
  int lg = 0;
  while ((1 << lg) < N) lg++;
  for (int k = 0; k < 18; k++)
    for (int i = 0; i < N; i++) r[i][k + 1] = r[r[i][k]][k];
}
void query() {
  int a, b;
  scanf("%d%d", &a, &b);
  if (a > b) swap(a, b);
  a--;
  b--;
  int ans = 0;
  for (int k = 18; k >= 0; k--) {
    if (r[a][k] <= b) {
      a = r[a][k];
      ans += (1 << k);
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) scanf("%lld", x + i);
  cin >> L;
  prepare();
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) query();
  return 0;
}
