#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> x(n + 1); for (int i = 0; i < n; i++) cin >> x[i];
  x[n] = 2e9 + 1;
  int l; cin >> l;
  VV<> dp; assign(dp, n + 1, __lg(n) + 1);
  for (int i = 0; i < n; i++) {
    int ok = i + 1, ng = n;
    while (ng - ok > 1) {
      int m = (ok + ng) / 2;
      if (x[m] - x[i] <= l) ok = m;
      else ng = m;
    }
    dp[i][0] = ok;
  }
  fill(dp[n].begin(), dp[n].end(), n);
  for (int j = 0; j < __lg(n); j++) for (int i = 0; i < n; i++) dp[i][j + 1] = dp[dp[i][j]][j];
  int q; cin >> q;
  for (int iq = 0; iq < q; iq++) {
    int a, b; cin >> a >> b, a--, b--;
    if (a > b) swap(a, b);
    int res = 0;
    while (true) {
      int i = 0;
      while (dp[a][i] < b) i++;
      i--;
      if (i < 0) break;
      a = dp[a][i];
      res += 1 << i;
    }
    cout << res + 1 << '\n';
  }
}