#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int N, L, Q;
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> a[i];
  cin >> L;
  cin >> Q;
  for (int q = 0; q < Q; ++q) {
    int b, e;
    cin >> b >> e;
    if (b > e) swap(b, e);
    int n_day = 0;
    int i = b + 1;
    while (i <= e) {
      if (a[i] - a[b] > L) {
        b = i - 1;
        ++n_day;
      } else {
        ++i;
      }
    }
    ++n_day;
    cout << n_day << endl;
  }
  return 0;
}
