#include<iostream>
#include<cstring>
using namespace std;
const int MAXL=200050;
const int BLOCK_NUM=2000;
const int BLOCK_SIZE=MAXL/BLOCK_NUM+100;
long long data[BLOCK_NUM][BLOCK_SIZE+10];
long long str[MAXL];
int cursize[BLOCK_NUM],next[BLOCK_NUM],indexpool[BLOCK_NUM];
int blocknum;
int n,q,a,b,L;
int getnew()
{
	return indexpool[blocknum++];
}
void deleteblock(int curblock)
{
	indexpool[--blocknum]=curblock;
}
void setup()
{
	for(int i=1;i<=BLOCK_NUM;i++)
		indexpool[i]=i;
	next[0]=-1;
	cursize[0]=0;
	blocknum=1;
}
int getblock(int &pos)
{
	int blockindex=0;
	while(blockindex!=-1&&cursize[blockindex]<pos)
	{
		pos-=cursize[blockindex];
		blockindex=next[blockindex];
	}
	return blockindex;
}
void addnewblock(int curblock,int nextblock,int num,long long str[])
{
	if(nextblock!=-1)
	{
		next[nextblock]=next[curblock];
		cursize[nextblock]=num;
		memcpy(data[nextblock],str,num*sizeof(long long));
	}
	next[curblock]=nextblock;
}
void in()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>str[i];
	}
	cin>>L>>q;
	setup();
	int tot=n;
	int curblock=0;
	while(tot>=BLOCK_SIZE)
	{
		int newblock=getnew();
		addnewblock(curblock,newblock,BLOCK_SIZE,str-tot+n);
		tot-=BLOCK_NUM;
		curblock=next[curblock];
	}
	if(tot>=0)
	{
		int newblock=getnew();
		addnewblock(curblock,newblock,tot,str+n-tot);
	}
}
int findpos(int blockindex,int num)
{
	int l=0,r=cursize[blockindex]-1;
	while(l<r)
	{
		if(r-l==1)
		{
			return l;
		}
		int mid=(l+r)/2;
		if(data[blockindex][mid]<num)
		{
			l=mid;
		}
		else if(data[blockindex][mid]==num)
		{
			return mid;
		}
		else
		{
			r=mid;
		}
	}
	return l;
}
void work()
{
	while(q)
	{
		cin>>a>>b;
		if(a>b)
			swap(a,b);
		int pos=a;
		int blockindex=getblock(pos);
		int num=data[blockindex][pos-1]+L;
		int ans=1;
		int blocklast=getblock(b);
		while(num<data[blocklast][b-1])
		{
			while(num>data[blockindex][cursize[blockindex]-1])
			{
				blockindex=next[blockindex];
			}
			num=data[blockindex][findpos(blockindex,num)]+L;
			ans++;
		}
		cout<<ans<<endl;
		q--;
	}
}
int main()
{
	in();
	work();
	return 0;
}