#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int f[18][MAXN], x[MAXN], n, l, q;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  cin >> l;
  int nl = 1, nr = 1, sum = 0;
  while (nl <= n) {
    while (nr < n && sum + x[nr + 1] - x[nr] <= l) {
      sum += x[nr + 1] - x[nr];
      nr++;
    }
    f[0][nl] = nr;
    sum -= (x[nl + 1] - x[nl]);
    nl++;
  }
  f[0][n] = n + 1;
  f[0][n + 1] = n + 1;
  for (int i = 1; i < 18; ++i)
    for (int j = 1; j <= n + 1; ++j) f[i][j] = f[i - 1][f[i - 1][j]];
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    int ans = 0;
    for (int j = 17; j >= 0 && x != y; --j) {
      if (f[j][x] <= y) {
        ans += (1 << j);
        x = f[j][x];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
