#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const long long mod = 1e6 + 3;
long long po(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
int n;
long long L;
int x[maxn];
int dp[maxn][20];
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
  }
  scanf("%lld", &L);
  x[n + 1] = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = lower_bound(x + 1, x + n + 2, x[i] + L + 1) - (x + 1);
  }
  int step = 1;
  for (step = 1; (1 << step) <= n; step++) {
    for (int k = 1; k <= n; k++) {
      dp[k][step] = dp[dp[k][step - 1]][step - 1];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int ans = 0;
    for (int i = step - 1; i >= 0; i--) {
      if (dp[a][i] <= b) {
        ans += (1 << i);
        a = dp[a][i];
      }
    }
    printf("%d\n", ans);
  }
}
int main() {
  solve();
  return 0;
}
