#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
int a[MAXN],n,L,go[19][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	scanf("%d",&L);
	for(int i=1;i<=n;++i){
		int p=upper_bound(a+1,a+n+1,a[i]+L)-a;
		go[0][i]=p-1;
	}
	for(int i=1;i<=18;++i)
		for(int j=1;j<=n;++j)
			go[i][j]=go[i-1][go[i-1][j]];
	int q;
	scanf("%d",&q);
	while(q--){
		int x,y,ans=0;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		for(int i=18;i>=0;--i)
			if(a[go[i][x]]<a[y])
				x=go[i][x],ans+=(1<<i);
		printf("%d\n",ans+1);
	}
	return 0;
}