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

#define int long
int a[100001],n;

int bs(int k)
{
	int ll=1, rr=n, mid=(ll+rr)/2;
	
	while(ll!=mid && rr!=mid)
	{
		if(a[mid]>=k) rr=mid;
		else ll=mid;
		mid=(ll+rr)/2;
	}
	
	for(int i=ll; i<rr; i++) if(a[i]>=k) return i;
}

main()
{
	int l,q;
	cin>>n;
	; for(int i=0;i<n;i++) scanf("%ld",&a[i]);
	cin>>l>>q;
	while(q--)
	{
		int x,y; scanf("%ld%ld",&x,&y);
		int ans=0, dis=a[x-1], pos; //cout<<a[y-1]<<endl;
		if(x<y) while(dis < a[y-1])
		{ 
			pos=bs(dis+l);
			pos= a[pos]==dis+l  ? pos : pos-1; 
			dis=a[pos];
			ans++;
		}
		else 
		{
			while(dis> a[y-1] && dis>0)
			{
				pos=bs(dis-l);
				dis=a[pos];
				ans++;
				//cout<<pos<<endl;
			}
		}
		printf("%ld\n",ans);
	}
	
}