#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
inline long long ni() {
  long long x;
  cin >> x;
  return x;
}
template <class T>
inline T nt() {
  T x;
  cin >> x;
  return x;
}
inline void print() {}
template <typename T, typename... TAIL>
inline void print(const T &t, TAIL... tail) {
  cout << t;
  print(tail...);
}
inline void input() { return; }
template <typename T, typename... TAIL>
inline void input(T &t, TAIL &...tail) {
  cin >> t;
  input(tail...);
}
const long long N = 2 * 1005001;
const long long inf = 1e9 + 7;
const double PI = 3.14159265359;
vector<pair<long long, long long> > q[N];
vector<long long> v;
long long L;
long long ans[N];
long long pr[N];
long long sfx[N];
long long prAns[N];
long long sfxAns[N];
void solve(long long l, long long r) {
  if (l + 1 == r) {
    for (auto it : q[l]) {
      ans[it.second] = 1;
    }
    return;
  }
  for (long long i = l; i < r; i++) {
    pr[i] = 0;
    sfx[i] = 0;
    prAns[i] = 0;
    sfxAns[i] = 0;
  }
  long long m = (l + r) / 2;
  long long last = m - 1;
  long long curd = 0;
  long long curAns = 1;
  long long ssfx0 = 0, ppref0 = 0;
  for (long long i = m - 1; i >= l; i--) {
    curd = abs(v[i] - v[last]);
    if (curd > L) {
      curd = 0;
      last = i + 1;
      curAns++;
    }
    if (curAns == 1) ssfx0 = curd;
    sfx[i] = curd;
    sfxAns[i] = curAns;
  }
  curd = 0;
  last = m;
  curAns = 1;
  for (long long i = m; i < r; i++) {
    curd = abs(v[i] - v[last]);
    if (curd > L) {
      curd = 0;
      last = i - 1;
      curAns++;
    }
    if (curAns == 1) ppref0 = curd;
    pr[i] = curd;
    prAns[i] = curAns;
  }
  for (long long i = m - 1; i >= l; i--) {
    while (!q[i].empty() && q[i].back().first >= m) {
      long long l = i, r = q[i].back().first, ind = q[i].back().second;
      q[i].pop_back();
      long long anss = prAns[r] + sfxAns[l];
      if ((prAns[r] > 1 ? ppref0 : pr[r]) + (sfxAns[l] > 1 ? ssfx0 : sfx[l]) +
              abs(v[m] - v[m - 1]) <=
          L)
        anss--;
      ans[ind] = anss;
    }
  }
  solve(l, m);
  solve(m, r);
}
signed main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  long long n = ni();
  for (long long i = 0; i < n; i++) v.push_back(ni());
  L = ni();
  long long Q = ni();
  for (long long i = 0; i < Q; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    if (l > r) swap(l, r);
    q[l].push_back({r, i});
  }
  for (long long i = 0; i < n; i++) {
    sort((q[i]).begin(), (q[i]).end());
  }
  solve(0, n);
  for (long long i = 0; i < Q; i++) {
    cout << ans[i] << '\n';
  }
}
