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

#define int long

main()
{
	int n,l,q;
	cin>>n;
	int a[n+1]; 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=lower_bound(a,a+n,dis+l)-a;
			pos= a[pos]==dis+l  ? pos : pos-1; 
			dis=a[pos];
			ans++;
		}
		else 
		{
			dis=a[x-1];
			//cout<<dis;
			while(dis> a[y-1] && dis>0)
			{
				pos=lower_bound(a, a+n, dis-l) - a;
				dis=a[pos];
				ans++;
				//cout<<pos<<endl;
			}
		}
		printf("%ld\n",ans);
	}
	
}