#include <bits/stdc++.h>
using namespace std;
long long n, l, q;
long long x[100010];
long long par[100010][20];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  cin >> l >> q;
  par[n - 1][0] = -1;
  for (int i = 0; i < n - 1; i++) {
    par[i][0] = upper_bound(x, x + n, x[i] + l) - x;
    par[i][0]--;
  }
  for (int j = 1; j < 20; j++) {
    for (int i = 0; i < n; i++) {
      if (par[i][j - 1] == -1) {
        par[i][j] = -1;
        continue;
      }
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    int ans = 0;
    int now = 19;
    while (a != b) {
      while (now > 0 && (par[a][now] == -1 || par[a][now] > b)) {
        if (par[a][now] == b) break;
        now--;
      }
      ans += (1 << now);
      a = par[a][now];
      if (now == 0) break;
    }
    cout << ans << "\n";
  }
}
