#include<bits/stdc++.h>
using namespace std;

using Table = vector<vector<int>>;
Table doubling(auto X, auto L) {
  int N = X.size();
  auto M = 0;
  while((1<<M) <= N) ++M;
  Table T(N, vector<int>(++M));
  for(auto i=0; i<N; ++i) {
    auto j = upper_bound(begin(X), end(X), X[i] + L) - begin(X) - 1;
    T[i][0] = j;
  }
  for(auto j=1; j<M; ++j) for(auto i=0; i<N; ++i) {
    auto k = T[i][j-1];
    T[i][j] = T[k][j-1];
  }
  return T;
}

int cost(auto T, auto a, auto b) {
  auto sum = 0;
  while(a < b) {
    for(auto i=0; i<T[a].size(); ++i) if(b <= T[a][i]) {
      if(i == 0) return sum + 1;
      --i;
      sum += 1<<i;
      a = T[a][i];
      break;
    }
  }
  assert(false);
}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for(auto& i: X) cin >> i, --i;
  int L;
  cin >> L;

  auto T = doubling(X, L);
  for(auto& i: X) i = X.back() - i;
  reverse(begin(X), end(X));
  auto R = doubling(X, L);

  int Q;
  cin >> Q;
  for(auto q=0; q<Q; ++q) {
    int a, b;
    cin >> a >> b;
    if(a < b) cout << cost(T, a-1, b-1) << endl;
    else      cout << cost(R, N-a, N-b) << endl;
  }
}
