#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0)
    return c;
  else
    return c + (long long)(1E9 + 7);
}
long long inf = (long long)1E12;
long long max(long long a, long long b) {
  if (a < b)
    return b;
  else
    return a;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
int main() {
  long long n;
  cin >> n;
  long long x[n];
  for (long long i = 0; i <= n - 1; i++) cin >> x[i];
  long long l, q;
  cin >> l >> q;
  long long dp[n][35];
  for (long long i = 0; i <= 34; i++) dp[n - 1][i] = n - 1;
  for (long long i = n - 2; i >= 0; i--) {
    dp[i][0] = upper_bound(x, x + n, x[i] + l) - x - 1;
    if (dp[i][0] == n) dp[i][0] = n - 1;
    for (long long j = 1; j <= 34; j++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    long long ans = 0;
    if (b == n - 1) {
      while (a < b) {
        long long t = lower_bound(dp[a], dp[a] + 35, b) - dp[a] - 1;
        if (t == -1) t++;
        ans += (long long)pow(2, t);
        a = dp[a][t];
      }
    } else {
      while (a < b) {
        long long t = upper_bound(dp[a], dp[a] + 35, b) - dp[a] - 1;
        ans += (long long)pow(2, t);
        a = dp[a][t];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
