#include <bits/stdc++.h>
using namespace std;
int n, q, l;
int x[100010];
int rgt[100010];
int cr;
int check(int a, int b, int nrpasi) {
  if (nrpasi == 0) return 0;
  if (rgt[a] >= b)
    return 1;
  else
    return check(rgt[a], b, nrpasi - 1);
}
int main() {
  int i, j;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> x[i];
  cin >> l >> q;
  int left = l + x[1], poz = 1;
  i = 1;
  while (i <= n) {
    if (left >= x[i]) {
      i++;
    } else {
      rgt[poz] = i - 1;
      poz++;
      left += x[poz] - x[poz - 1];
    }
  }
  i--;
  for (; poz <= n; poz++) rgt[poz] = i;
  for (i = 1; i <= n; i++) cout << rgt[i] << ' ';
  cout << '\n';
  int a, b, p, sol;
  while (q--) {
    cin >> a >> b;
    if (a > b) {
      p = b;
      b = a;
      a = p;
    }
    for (p = 1; p <= n; p *= 2)
      ;
    for (sol = n; p > 0; p /= 2) {
      if (a + sol - p >= a)
        if (check(a, b, sol - p)) sol -= p;
    }
    cout << sol << '\n';
  }
  return 0;
}
