import sys
from bisect import bisect_left, bisect_right
from functools import lru_cache


@lru_cache(maxsize=None)
def solve(l, r):
    if l >= r:
        return 0
    return solve(rightmost[l], r) + 1


n = int(input())
xxx = list(map(int, input().split()))
l = int(input())

rightmost = []
for x in xxx:
    rightmost.append(bisect_right(xxx, x + l) - 1)

buf = []
q = int(input())
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    buf.append(solve(a, b))
print('\n'.join(map(str, buf)))
