#include <bits/stdc++.h>
#pragma GCC optimize("O3,Ofast,unroll-loops")
using namespace std;
using VI = vector<long>;
long n, l, step;
long xs[101010];
VI stepdays[101010];
void calc_times(long v) {
  long cnt = 0;
  long cur = v;
  for (long i = cur + 1; i < n; i++) {
    if (xs[i] - xs[cur] <= l) {
      if (i + 100 < n && xs[i + 100] - xs[cur] <= l) {
        i += 100;
      }
    } else {
      cnt++;
      i--;
      cur = i;
      if (cnt % step == 0) {
        stepdays[v].push_back(cur);
        if (stepdays[cur].size()) {
          for (long j : stepdays[cur]) {
            stepdays[v].push_back(j);
          }
          return;
        }
      }
    }
  }
}
long get_days(long left, long right) {
  if (left == right) {
    return 0;
  }
  if (xs[right] - xs[left] <= l) {
    return 1;
  }
  long ret = 0;
  long cur = left;
  for (long i = left + 1; i <= right; i++) {
    if (xs[i] - xs[cur] <= l) {
      if (i + 100 < right && xs[i + 100] - xs[cur] <= l) {
        i += 100;
      }
      if (i == right) {
        return ret + 1;
      }
    } else {
      ret++;
      i--;
      cur = i;
    }
  }
  cout << "ERROR" << endl;
  exit(1);
}
void init() {
  step = sqrt(n);
  for (long i = n - 2; i >= 0; i--) {
    calc_times(i);
  }
}
long query(long left, long right) {
  long i;
  for (i = 0; i < stepdays[left].size(); i++) {
    if (stepdays[left][i] > right) break;
  }
  if (i == 0) {
    return get_days(left, right);
  } else {
    return i * step + get_days(stepdays[left][i - 1], right);
  }
}
int main() {
  cin >> n;
  for (long i = 0; i < n; i++) {
    cin >> xs[i];
  }
  cin >> l;
  init();
  long q;
  cin >> q;
  for (long i = 0; i < q; i++) {
    long a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << query(min(a, b), max(a, b)) << endl;
  }
}
