#include<bits/stdc++.h>
#define N 100010
#define swap(a,b) a^=b^=a^=b
using namespace std;
int l,n,m;
int f[N][25]={},a[N]={};
int read(){int s=0,w=1;char ch=getchar();while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();if(ch=='-')w=-1;while(ch<='9'&&ch>='0')s=s*10+ch-'0',ch=getchar();return s*w;}
struct rode{int l,r;}e[N*2]={};
int main()
{
		n=read();
		for(int i=1;i<=n;++i)a[i]=read();
		l=read();m=read();
		for(int i=1;i<=m;++i)e[i].l=read(),e[i].r=read(),e[i].l<=e[i].r?0:swap(e[i].l,e[i].r);
		for(int i=1;i<=n;++i)
		{
				int k=i;
				while(k<=n&&a[k]<=a[i]+l)++k;
				f[i][0]=k-1;
				// printf("%d\n",f[i][0]);
		}
		// for(int j=1;j<=25;++j){
		//  for(int i=1;i<=n;++i)
 		//   	f[i][j]=f[f[i][j-1]][j-1],printf("%d ",f[i][j]);
		// 	puts("");
		}
		for(int i=1;i<=m;++i)
		{
				int ll=e[i].l,s=0;bool p=0;
				for(int j=25;j>=0;--j)if(f[ll][j]<=e[i].r)ll=f[ll][j],s+=(1<<j),p=1;
				if(!p)s=1;
				printf("%d\n",s);
		}
		return 0;
}
