#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using P = pair<int, int>;
long n, l, step;
long xs[101010];
VI stepdays[101010];
void calc_times(int v) {
  int cnt = 0;
  int cur = v;
  int i = cur + 1;
  while (i < n) {
    for (; i < n; i++) {
      if (xs[i] - xs[cur] <= l) {
      } else {
        cur = i - 1;
        cnt++;
        if (cnt % step == 0) {
          stepdays[v].push_back(cur);
        }
        break;
      }
    }
  }
}
int get_days(int left, int r) {
  int ret = 0;
  int cur = left;
  int i = cur + 1;
  while (i < n) {
    for (; i < n; i++) {
      if (xs[i] - xs[cur] <= l) {
        if (i == r) {
          return ret + 1;
        }
      } else {
        cur = i - 1;
        ret++;
        break;
      }
    }
  }
  exit(1);
}
void init() {
  step = sqrt(n);
  for (int i = 0; i < n - 1; i++) {
    calc_times(i);
  }
}
int query(int left, int right) {
  int 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 (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 << query(min(a, b), max(a, b)) << endl;
  }
}
