#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &str, vector<T> &a) {
  for (auto &i : a) {
    str << i << " ";
  }
  return str;
}
template <class T>
istream &operator>>(istream &str, vector<T> &a) {
  for (auto &i : a) {
    str >> i;
  }
  return str;
}
template <class T>
ostream &operator<<(ostream &str, pair<T, T> &a) {
  str << a.first << " " << a.second;
  return str;
}
template <class T>
istream &operator>>(istream &str, pair<T, T> &a) {
  str >> a.first >> a.second;
  return str;
}
void solve();
signed main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(6);
  solve();
  return 0;
}
const long long MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;
long long N, L, Q;
void dfs(long long v, long long p, vector<vector<long long>> &g,
         vector<vector<long long>> &mx, vector<vector<long long>> &pr) {
  mx[v][0] = p;
  pr[v][0] = p;
  for (long long k = 1; k < 30; ++k) {
    pr[v][k] = pr[pr[v][k - 1]][k - 1];
  }
  for (long long k = 1; k < 30; ++k) {
    mx[v][k] = max(mx[v][k - 1], mx[pr[v][k - 1]][k - 1]);
  }
  for (auto u : g[v]) {
    if (u != p) {
      dfs(u, v, g, mx, pr);
    }
  }
}
long long query(long long a, long long b, vector<vector<long long>> &mx,
                vector<vector<long long>> &pr) {
  long long s = 0;
  for (long long k = 29; k >= 0; --k) {
    if (mx[a][k] < b) {
      s += (1ll << k);
      a = pr[a][k];
    }
  }
  s++;
  return s;
}
void solve() {
  cin >> N;
  vector<long long> first(N + 1);
  for (long long i = 1; i <= N; ++i) {
    cin >> first[i];
  }
  cin >> L >> Q;
  vector<vector<long long>> g1(MAXN), g2(MAXN),
      mx1(MAXN, vector<long long>(30)), pr1(MAXN, vector<long long>(30)),
      mx2(MAXN, vector<long long>(30)), pr2(MAXN, vector<long long>(30));
  for (long long i = 1; i <= N; ++i) {
    long long l = i + 1, r = N + 1;
    while (r - l > 1) {
      long long mid = (r + l) / 2;
      if (first[mid] - first[i] <= L) {
        l = mid;
      } else {
        r = mid;
      }
    }
    if (l == N + 1) l = 0;
    g1[l].push_back(i);
    g1[i].push_back(l);
  }
  dfs(N, 0, g1, mx1, pr1);
  vector<pair<long long, long long>> qs(Q);
  vector<long long> ans(Q);
  for (long long _ = 0; _ < Q; ++_) {
    long long a, b;
    cin >> a >> b;
    qs[_] = {a, b};
    if (a < b) {
      ans[_] = query(a, b, mx1, pr1);
    }
  }
  vector<long long> second(N + 1);
  second[0] = -INF;
  for (long long i = 1; i <= N; ++i) {
    second[i] = -first[N - i + 1];
  }
  for (long long i = 1; i <= N; ++i) {
    long long l = i + 1, r = N + 1;
    while (r - l > 1) {
      long long mid = (r + l) / 2;
      if (second[mid] - second[i] <= L) {
        l = mid;
      } else {
        r = mid;
      }
    }
    if (l == N + 1) l = 0;
    g2[l].push_back(i);
    g2[i].push_back(l);
  }
  dfs(N, 0, g2, mx2, pr2);
  for (long long i = 0; i < Q; ++i) {
    if (qs[i].first > qs[i].second) {
      ans[i] = query(N - qs[i].first + 1, N - qs[i].second + 1, mx2, pr2);
    }
  }
  for (long long i = 0; i < Q; ++i) {
    cout << ans[i] << '\n';
  }
}
