from bisect import bisect_right

N = int(input())
X = list(map(int, input().split()))
L = int(input())
Q = int(input())

def calc(i, a, b):
    now = a
    res = 0
    while True:
        # print("dbg", now, X[now])
        # print(bisect_left(X, X[now] + L))
        # print(i, now)
        if now >= b:
            break
        now = bisect_right(X, X[now] + L) - 1
        res += 1
    return res


for q in range(Q):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    a -= 1
    b -= 1
    print(calc(q, a, b))
