#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 1e5 + 20, LG = 20, inf = 1e9 + 20;
int n, l, q, x[N], nxt[LG][N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i];
  cin >> l;
  for (int i = n - 1, p = n - 1; i >= 0; i--) {
    while (x[p] - x[i] > l) p--;
    nxt[0][i] = p;
  }
  for (int i = 1; i < LG; i++)
    for (int j = 0; j < n; j++) nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
  cin >> q;
  while (q--) {
    int a, b, ans = inf, cur = 0;
    cin >> a >> b;
    a--, b--;
    if (a > b) swap(a, b);
    for (int i = LG - 1; i >= 0; i--) {
      if (nxt[i][a] >= b) {
        ans = min(ans, cur + (1 << i));
      } else {
        cur += (1 << i);
      }
    }
    cout << ans << '\n';
  }
}
