#設定
import sys
input = sys.stdin.buffer.readline
import bisect

INF = float("inf")

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	X = getlist()
	X.append(INF)
	L = int(input())
	double = [[0] * (N + 1) for i in range(20)]
	for i in range(N):
		p = bisect.bisect_left(X, X[i] + L + 1)
		double[0][i] = p - 1
	for i in range(20):
		double[i][N] = INF
	
	for i in range(1, 20):
		for j in range(N):
			double[i][j]  = double[i - 1][double[i - 1][j]]

	# for i in range(5):
	# 	print(double[i])

	Q = int(input())
	for i in range(Q):
		a, b = sorted(getlist())
		a -= 1; b -= 1
		ans = 0
		for j in range(20):
			if double[19 - j][a] < b:
				a = double[19 - j][a]
				ans += 1 << (19 - j)

		print(ans + 1)

if __name__ == '__main__':
	main()