#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using P = pair<int, int>;
long n, l;
long xs[101010];
map<int, VI> times;
void calc_times(int v) {
  VI t(n);
  int cur = v;
  int i = cur + 1;
  while (i < n) {
    for (; i < n; i++) {
      if (xs[i] - xs[cur] <= l) {
        t[i] = t[cur] + 1;
      } else {
        cur = i - 1;
        break;
      }
    }
  }
  cur = v;
  i = cur - 1;
  while (i >= 0) {
    for (; i >= 0; i--) {
      if (xs[cur] - xs[i] <= l) {
        t[i] = t[cur] + 1;
      } else {
        cur = i + 1;
        break;
      }
    }
  }
  times[v] = VI(t);
}
void init() {
  for (int i = 0; i < n; i += 1) {
    calc_times(i);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  cin >> l;
  init();
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << times[a][b] << endl;
  }
}
