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

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=1e5+5,L=17;
int a[N],f[N][L];

int main()
{
//	freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	int l;
	cin>>l;
	rep(j,0,L-1)f[n][j]=n;
	int now=n;
	per(i,n-1,1)
	{
		while(a[now]-a[i]>l)--now;
		f[i][0]=now;
		rep(j,1,L-1)f[i][j]=f[f[i][j-1]][j-1];
	}
	int m;
	cin>>m;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		int ans=0;
		per(j,L-1,0)
		if(f[x][j]<y)
		{
			ans+=1<<j;
			x=f[x][j];
		}
		printf("%d\n",ans+1);	
	}
}