#include <bits/stdc++.h>
const long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;
const int N = 1e5 + 1;
int n;
long long L;
long long a[N], dp[N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> L;
  dp[n] = 0;
  dp[n - 1] = 1;
  for (int i = n - 2; i >= 1; i--) {
    int l, r;
    l = 0;
    r = n - i + 1;
    while (r - l > 1) {
      int m = (l + r) >> 1;
      if (i + m > n) cout << 1 / 0 << endl;
      if (a[i + m] - a[i] <= L)
        l = m;
      else
        r = m;
    }
    dp[i] = dp[i + l] + 1;
  }
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    cout << abs(dp[y] - dp[x]) << endl;
  }
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(3);
  int step;
  step = 1;
  for (int i = 1; i <= step; i++) {
    solve();
  }
}
