from bisect import bisect_right

N = int(input())
x = list(map(int, input().split()))
rx = list(sorted(map(lambda xx: -xx, x)))
L = int(input())
Q = int(input())
for _ in range(Q):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a < b:
        t = x[a]
        cnt = 0
        while True:
            t += L
            # print(t, x[b])
            cnt += 1
            i = bisect_right(x, t) - 1
            if i >= b:
                print(cnt)
                break
            else:
                t = x[i]
    else:
        t = rx[N - 1 - a]
        cnt = 0
        while True:
            t += L
            cnt += 1
            # print(rx, t, rx[N - 1 - b])
            i = bisect_right(rx, t) - 1
            if i >= N - 1 - b:
                print(cnt)
                break
            else:
                t = rx[i]
