#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int b[100005];
int s[100005];
int l;
int task;
int st, nt;
int getans(int x, int dep) {
  if (x >= nt)
    return dep;
  else
    return getans(s[x], dep + 1);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) b[i] = a[i] - a[i - 1];
  cin >> l;
  int q = 0;
  int j = 1;
  for (int i = 0; i < n; i++) {
    q -= b[i];
    while (q + b[j] <= l && j < n) {
      q += b[j];
      j++;
    }
    s[i] = j - 1;
  }
  cin >> task;
  for (int tt = 0; tt < task; tt++) {
    cin >> st >> nt;
    st--;
    nt--;
    if (st > nt) swap(st, nt);
    cout << getans(st, 0) << endl;
  }
  return 0;
}
