#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX 100010
ll N,Q,L;
ll x[MAX],a,b;

int nex[MAX][80];

void compute() {
  rep(i,N) {
    nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1;
    assert( nex[i][0] != 0 );
  }

  rep(j,70) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j];
  cin >> Q;
  rep(_,Q) {
    cin >> a >> b;
    --a, --b;
    if( !( a < b ) ) swap(a,b);
    ll cost = 0;
    for(int i=69;i>=0;--i) {
      if( nex[a][i] < b ) {
	cost += (1LL<<i);
	a = nex[a][i];
      }
    }
    cout << cost+1 << endl;
  }
}

int main() {
  cin >> N;
  rep(i,N) cin >> x[i];
  cin >> L;
  compute();
  return 0;
}
