#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
int n,z;
int t[111111];
int next[30][111111];
int q;

int che(int x){

	int l=x+1,r=n-1,mid=(r+l)/2;
	
	while(r-l>1){
		int ab=t[mid]-t[x];
		if(ab>z)r=mid;
		else l=mid;
		mid=(r+l)/2;
	}

	return l;
}

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	cin>>z;

	rep(i,n){
		next[0][i]=che(i);
	}

	rep(i,29){
		rep(j,n){
			if(next[i][j]==n)next[i+1][j]=n;
			else next[i+1][j]=next[i][next[i][j]];
		}
	}



	cin>>q;
	rep(i,q){
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		a--;b--;
		int ans=0,now=a;	
		for(int j=25;j>=0;j--){
			if(next[j][now]>b)continue;
			ans+=(1<<j);
			now=next[j][now];
		}
		cout<<ans<<endl;
	}
	return 0;
}
