import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	
	int n = readln.chomp.to!int;
	int[] xs = readln.chomp.split.map!(to!int).array;
	int l = readln.chomp.to!int;
	
	int[] ys; ys.length = n;
	for(int i = 0, j = 0; j < n; j ++){
		while(xs[i] + l < xs[j]) i += 1;
		for(int ii = i; ii < j; ii ++) ys[ii] = j;
		}
	
	int[long] memo; // a * 10000 + b -> distance from a to b
	int[int] maxb; // a -> b: max b where a * 10000 + b is in memo
	
	int q = readln.chomp.to!int;
	foreach(qi; 0 .. q){
		int[] ab = readln.chomp.split.map!(to!int).array;
		int a, b;
		if(ab[0] < ab[1]) a = ab[0] - 1, b = ab[1] - 1;
		else a = ab[1] - 1, b = ab[0] - 1;
		
		int ans = 0;
		for(int i = a; i < b; ){
			if(i in maxb){
				if(i * 10000 + b in memo){
					ans += memo[i * 10000 + b];
					break;
					}
				else{
					ans += memo[i * 10000 + maxb[i]];
					i = maxb[i];
					}
				}
			else{
				ans += 1;
				maxb[a] = ys[i];
				memo[a * 10000 + a] = 0;
				for(int ii = i + 1; ii <= ys[i]; ii ++){
					memo[a * 10000 + ii] = memo[a * 10000 + i] + 1;
					}
				i = ys[i];
				}
			}
		
		ans.writeln;
		}
	
	}