#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,q,i,j,dp[1<<18][18],l,r,x,y,ans,now,wx[100005];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++) cin>>wx[i];
	cin>>m;
	for (i=1;i<=n;i++)
	{
		while (j<n&&wx[i]+m>=wx[j+1]) j++;
		dp[i][0]=j;
	}
	for (j=1;j<=17;j++)
	{
		for (i=1;i<=n;i++)
		{
			dp[i][j]=dp[dp[i][j-1]][j-1];
		}
	}
	cin>>q;
	for (i=1;i<=q;i++)
	{
		cin>>l>>r;
		if (l>r) swap(l,r);
		ans=0;
		for (j=17;j>=0;j--)
		{
			while (dp[l][j]<r)
			{
				l=dp[l][j];
				ans+=1<<j;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}