#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100010
#define int ll

int N,L,Q;
int A[maxn];
vi adj[maxn];

int twok[maxn][100],depth[maxn];

void twokdecomp(int x,int p){
	twok[x][0] = p;
	for (int i=1;i<=18;i++){ //i <= logmaxn
		if (twok[x][i-1] == -1) break;
		twok[x][i] = twok[twok[x][i-1]][i-1];
	}
	for (auto i: adj[x]){
		if (i != p){
			depth[i] = depth[x] + 1;
			twokdecomp(i,x);
		}
	}
}

int kth_parent(int x,int k){
	
	for (int i=0;i<=18;i++){
		if (k&(1<<i)){
			x = twok[x][i];
		}
		if (x==-1) break;
	}
	return x;

}



int32_t main(){
	fast;
	
	cin>>N;
	FOR(i,1,N) cin>>A[i];
	
	cin>>L>>Q;
	
	FOR(i,1,N-1){
		
		int idx = upper_bound(A+1,A+N+1,A[i] + L) - A;
		
		idx--;
		
		if (i == idx) continue;
		adj[i].pb(idx);
		adj[idx].pb(i);
		
	}
	
	mem(twok,-1);
	
	twokdecomp(N,-1);
		
	FOR(i,0,Q-1){
		int a,b; cin>>a>>b;
		if (a > b) swap(a,b);
		
		int l=0,r=depth[a]+10;
		
		while (l + 1 < r){
			
			int mid = (l+r)/2;
			//cout<<mid<<' '<<kth_parent(a,mid)<<'\n';

			if (kth_parent(a,mid) == -1) r = mid;
			else if (kth_parent(a,mid) > b) r = mid;
			else l = mid;
		}
		
		while (kth_parent(a,l) < b){
			l++;
		}
		cout<<l<<'\n';
		
	}
			
	
	
}

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 1000010;
int n;
int a[N];
int L, q, ans, lst;
int dp[N][21];
int pow[21];
int main() {
	memset(dp, 0x3f, sizeof(dp));
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	scanf("%d", &L);
	scanf("%d", &q);
	pow[0] = 1;
	lst = 1;
	for (int i = 1; i <= n; i++) {
		while (a[i] > a[lst] + L) {
			dp[lst++][0] = i - 1;
		}
	}
	for (int j = 1; j <= 20; j++) {
		pow[j] = pow[j - 1] << 1; 
		for (int i = 1; i <= n; i++) {
			if (dp[i][j - 1] < 0x3f3f3f3f) dp[i][j] = dp[dp[i][j - 1]][j - 1];
		}
	}
	while (q--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		ans = 0;
		for (int i = 20; i >= 0; i--) {
			if (dp[x][i] < y) {
				x = dp[x][i];
				ans += pow[i];
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}