#include <bits/stdc++.h>
using namespace std;
int v[100010];
pair<int, int> d[100010][25];
int main() {
  int n, l;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> v[i];
  cin >> l;
  for (int i = 0; i < n; i++) {
    int st = i, dr = n - 1, mij, r = i;
    while (st <= dr) {
      mij = (st + dr) / 2;
      int diff = v[mij] - v[i];
      if (diff <= l) {
        st = mij + 1;
        r = mij;
      } else
        dr = mij - 1;
    }
    d[i][0].first = r;
    if (mij != i)
      d[i][0].second = 1;
    else
      d[i][0].second = 0;
  }
  int i;
  for (i = 1; (1 << (i)) <= n; i++) {
    for (int j = 0; j < n; j++) {
      int inter = d[j][i - 1].first;
      int dest = d[inter][i - 1].first;
      d[j][i].first = dest;
      d[j][i].second = d[j][i - 1].second + d[inter][i - 1].second;
    }
  }
  int lgo = i - 1;
  int q;
  cin >> q;
  while (q--) {
    int a, b, lg = lgo;
    cin >> a >> b;
    if (a > b) swap(a, b);
    a--;
    b--;
    int rez = 0;
    while (a < b) {
      if (d[a][lg].first > b) {
        lg--;
      } else {
        rez += d[a][lg].second;
        a = d[a][lg].first;
      }
    }
    cout << rez << '\n';
  }
  return 0;
}
