#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
const int maxn = 1e5 + 10;
int s[maxn], n, L, Q;
int cnt[maxn], c[maxn];

int main(){
	s[0]=0;
	while(~scanf("%d", &n)){
		for(int i=1; i<=n; i++) scanf("%d", &s[i]);
		scanf("%d", &L);
		
		for(int i=1; i<n; i++){
			int tmp=cnt[i-1];
			while(s[tmp]-s[i]<=L && tmp <=n) tmp++;
			cnt[i]=tmp-1;
		}
		int day=1,st=n;
		while(day<=1000&&st>0){
			int ss=st+1;
			while(s[ss]-s[st-1]<=L&&st>=1) {
				c[st]=n;
				st--;
			}
			day++;			
		}
		while(st>0){
			c[st]=c[cnt[st]];
			int v=c[st];
			while(s[c[st]]-s[v]<=L)	v--;
			c[st]=v+1;	st--;
		}
		scanf("%d", &Q);
		while(Q--){
			int a, b, ans=0;
			scanf("%d%d", &a, &b);
			if(a>b) swap(a,b);
			int tmp=a, sum=0;
			while(c[a]<b){
				a=c[a];
				ans+=1000;
			}
			while(a<b){
				a=cnt[a];
				ans++;
			}
			printf("%d\n", ans);
		}
	}
	return 0;
