#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define ll long long
#define N 200005
int n,L,q,l,r;
ll res,a[N],f[N][35];
using namespace std;
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	n=read();
	for (int i=0;i<n;i++)	a[i]=read();
	L=read();q=read();
	for (int i=0;i<n;i++){
		int po=upper_bound(a,a+n,a[i]+L)-a;
		if (po==n)	f[i+1][0]=n;
		else 	f[i+1][0]=po;
	}	
	for (int j=1;j<=30;j++)
		for (int i=1;i<=n;i++)
			f[i][j]=f[f[i][j-1]][j-1];
	while (q--){
		res=0;
		l=read();r=read();
		if (l>r)	swap(l,r);
		for (int i=30;i>=0;i--){
			if (f[l][i]<r){
				res+=(ll)(1<<i);
				l=f[l][i];
			}
		}
		cout<<res+1<<endl;
	}
	return 0;
}