#include <bits/stdc++.h>
using namespace std;
const long long INF = std::numeric_limits<long long>::max();
const long long MOD = 1e9 + 7;
const long double PI = 3.141592653589793;
int p[1 << 20], t[1 << 20], n, L, q;
int main() {
  cin >> n;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> p[i];
  cin >> L;
  t[n - 1] = 0;
  for (__typeof(0) i = (n - 1) - ((n - 1) > (0)); i != (0) - ((n - 1) > (0));
       i += 1 - 2 * ((n - 1) > (0)))
    t[i] = t[upper_bound(p, p + n, p[i] + L) - p - 1] + 1;
  cin >> q;
  for (__typeof(q) i = (0) - ((0) > (q)); i != (q) - ((0) > (q));
       i += 1 - 2 * ((0) > (q))) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    x--, y--;
    cout << (t[x] - t[y] == 0 ? 1 : t[x] - t[y]) << "\n";
  }
}
