#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline int ni() {
  int 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 int N = 2 * 1005001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;
vector<pair<int, int> > q[N];
vector<int> v;
int L;
int ans[N];
int pr[N];
int sfx[N];
int prAns[N];
int sfxAns[N];
void solve(int l, int r) {
  if (l + 1 == r) {
    for (auto it : q[l]) {
      ans[it.second] = 1;
    }
    return;
  }
  for (int i = l; i <= r; i++) {
    pr[i] = 0;
    sfx[i] = 0;
    prAns[i] = 0;
    sfxAns[i] = 0;
  }
  int m = (l + r) / 2;
  int last = m - 1;
  int curd = 0;
  int curAns = 0;
  int ssfx0 = 0, ppref0 = 0;
  for (int i = m - 1; i >= l; i--) {
    curd = abs(v[i] - v[last]);
    if (curd > L) {
      curd = 0;
      last = i;
      curAns++;
    }
    if (curAns == 0) ssfx0 = curd;
    sfx[i] = curd;
    sfxAns[i] = curAns;
  }
  curd = 0;
  last = m;
  curAns = 0;
  for (int i = m; i < r; i++) {
    curd = abs(v[i] - v[last]);
    if (curd > L) {
      curd = 0;
      last = i;
      curAns++;
    }
    if (curAns == 0) ppref0 = curd;
    pr[i] = curd;
    prAns[i] = curAns;
  }
  for (int i = m - 1; i >= l; i--) {
    while (!q[i].empty() && q[i].back().first >= m) {
      int l = i, r = q[i].back().first, ind = q[i].back().second;
      q[i].pop_back();
      if (sfxAns[l] == 0 && prAns[r] == 0) {
        if (sfx[l] + pr[r] + abs(v[m] - v[m - 1]) <= L)
          ans[ind] = 1;
        else
          ans[ind] = 2;
      } else if (sfxAns[l] && !prAns[r]) {
        int anss = sfxAns[l] + 1;
        if (ssfx0 + pr[r] + abs(v[m] - v[m - 1]) <= L)
          ;
        else
          anss++;
        ans[ind] = anss;
      } else if (!sfxAns[l] && prAns[r]) {
        int anss = prAns[r] + 1;
        if (ppref0 + sfx[l] + abs(v[m] - v[m - 1]) <= L)
          ;
        else
          anss++;
        ans[ind] = anss;
      } else {
        int anss = prAns[r] + sfxAns[l] + 1;
        if (ppref0 + ssfx0 + abs(v[m] - v[m - 1]) <= L)
          ;
        else
          anss++;
        ans[ind] = anss;
      }
    }
  }
  solve(l, m);
  solve(m, r);
}
signed main() {
  int n = ni();
  for (int i = 0; i < n; i++) v.push_back(ni());
  L = ni() + 1;
  int Q = ni();
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    if (l > r) swap(l, r);
    q[l].push_back({r, i});
  }
  for (int i = 0; i < n; i++) {
    sort((q[i]).begin(), (q[i]).end());
  }
  solve(0, n);
  for (int i = 0; i < Q; i++) {
    cout << ans[i] << '\n';
  }
}
