#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int r[20][101010];

int f(int s, int t, int x){
  int cur=s;
  rep(i,18) if((x>>i)&1){
    cur=r[i][cur];
  }
  if(cur>=t) return 1;
  else return 0;
}

int main(){
  int N;cin>>N;
  int X[N];
  rep(i,N) cin>>X[i];
  int L; cin>>L;
  rep(i,N){
    int x=upper_bound(X,X+N,X[i]+L)-X;
    r[0][i]=x-1;
  }
  rep(i,18) rep(j,N) r[i+1][j]=r[i][r[i][j]];
  int Q; cin>>Q;
  rep(i,Q){
    int a,b; cin>>a>>b; a--,b--;
    if(a>b) swap(a,b);
    int ok=N,ng=0;
    while(abs(ok-ng)>1){
      int mid=(ok+ng)/2;
      if(f(a,b,mid)) ok=mid;
      else ng=mid;
    }
    cout<<ok<<endl;
  }
  return 0;
}
