#include <bits/stdc++.h>
using namespace std;
int N;
int x[100010];
int L, Q;
int a[100010];
int b[100010];
int memo[100010][18];
int g(int a, int r) {
  if (memo[a][r] != -1) return memo[a][r];
  int ans = 0;
  if (r == 0) {
    int now = a;
    while (now + 1 < N && x[now + 1] - x[a] <= L) {
      now++;
    }
    ans = now;
  } else {
    int t = g(a, r - 1);
    if (t == N - 1) {
      ans = N - 1;
    }
    ans = g(t, r - 1);
  }
  return memo[a][r] = ans;
}
int h(int n) {
  int ans = 0;
  int m = n;
  while (m > 0) {
    m = (m >> 1);
    if (m == 0) break;
    ans++;
  }
  return ans;
}
int f(int a, int day) {
  if (day == 0) return a;
  int s = h(day);
  return f(g(a, s), day - (1 << s));
}
int mini(int a, int b) {
  int lb = 0;
  int ub = 100010;
  while (ub - lb > 1) {
    int t = (lb + ub) / 2;
    int s = f(a, t);
    if (b <= s) {
      ub = t;
    } else {
      lb = t;
    }
  }
  return ub;
}
int main() {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> x[i];
  }
  cin >> L >> Q;
  for (auto i = 0; i < Q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  fill(&memo[0][0], &memo[0][0] + 100010 * 18, -1);
  for (auto i = 0; i < Q; i++) {
    cout << mini(a[i], b[i]) << endl;
  }
}
