#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
template <typename T, typename S>
void amax(T &x, S y) {
  if (x < y) x = y;
}
template <typename T, typename S>
void amin(T &x, S y) {
  if (y < x) x = y;
}
int dp[100010][21];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n;
  cin >> n;
  vi64 x(n);
  for (int i = 0; i < int(n); i++) cin >> x[i];
  int l, q;
  cin >> l >> q;
  for (int i = 0; i < int(n); i++)
    dp[i][0] = upper_bound((x).begin(), (x).end(), x[i] + l) - x.begin() - 1;
  for (int i = 0; i < int(20); i++)
    for (int j = 0; j < int(n); j++) dp[j][i + 1] = dp[dp[j][i]][i];
  for (int _ = 0; _ < int(q); _++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ans = 0;
    for (int i = int(20) - 1; i >= 0; i--)
      if (dp[a][i] <= b) {
        a = dp[a][i];
        ans += 1 << i;
      }
    cout << ans << endl;
  }
  return 0;
}
