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
	
	for(int i = 0; i < n; i += 120){
		memo[i * 10000 + i] = 0;
		for(int j = i; j < n; j = ys[j]){
			for(int jj = j + 1; jj <= ys[j]; jj +=1){
				memo[i * 10000 + jj] = memo[i * 10000 + j] + 1;
				}
			if(ys[j] == 0) break;
			}
		}
	
	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; i = ys[i]){
			if(i * 10000 + i in memo){
				ans += memo[i * 10000 + b];
				break;
				}
			else{
				ans += 1;
				}
			}
		
		ans.writeln;
		}
	
	
	}