#include <bits/stdc++.h>
using namespace std;
int n, i, j, a[100002], dis[100002], l, q, r[100002], f[100002][22];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  cin >> l >> q;
  for (i = 1; i <= n; i++) {
    int pos = lower_bound(a + 1, a + n + 1, a[i] + l) - a;
    if (a[pos] == a[i] + l)
      f[i][0] = pos;
    else
      f[i][0] = pos - 1;
  }
  for (j = 0; (1 << j) <= n; j++) {
    for (i = 1; i <= n; i++) {
      if (f[i][j] == 0)
        f[i][j + 1] = 0;
      else
        f[i][j + 1] = f[f[i][j]][j];
    }
  }
  for (i = 1; i <= q; i++) {
    int x, y, ans = 0;
    cin >> x >> y;
    if (x > y) swap(x, y);
    for (j = log2(1.0 * n); j >= 0; j--) {
      if (f[x][j] <= y) ans += pow(2, j), x = f[x][j];
    }
    cout << ans << endl;
  }
  return 0;
}
