#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecint x(n);
  for(auto&& e:x)cin>>e;
  int l;
  cin>>l;
  vector<vecint> dp(18, vecint(n));
  vector<vecint> dp2(18, vecint(n));
  int j = 0, k = 0;
  REP(i,n) {
    while (j < n && x[j] - x[i] <= l) ++j;
    while (x[i] - x[k] > l) ++k;
    dp[0][i] = j-1;
    dp2[0][i] = k;
  }
  REP(i,17)REP(j,n) {
    dp[i+1][j] = dp[i][dp[i][j]];
    dp2[i+1][j] = dp2[i][dp2[i][j]];
  }
  int q;
  cin>>q;
  REP(cnt,q) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    int sum = 0;
    if (a < b) {
      for (int j=17; j>=0; --j) {
        if (dp[j][a] <= b) {
          sum += 1 << j;
          a = dp[j][a];
        }
      }
    } else {
      for (int j=17; j>=0; --j) {
        if (dp2[j][a] >= b) {
          sum += 1 << j;
          a = dp2[j][a];
        }
      }
    }
    if (a != b) ++sum;
    cout<<sum<<"\n";
  }
  return 0;
}
