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

leftX = [-1] * N
rightX = [-1] * N
left = 0

for i, x in enumerate(X):
    while left < N and X[left] < x - L:
        left += 1
    leftX[i] = left

right = N - 1
for i in range(N)[:: -1]:
    x = X[i]
    while right >= 0 and X[right] > x + L:
        right -= 1
    rightX[i] = right

ans = []
for _ in range(Q):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    day = 0
    if fr < to:
        while fr < to:
            day += 1
            fr = rightX[fr]
    else:
        while fr > to:
            day += 1
            fr = leftX[fr]
    ans.append(day)

print(*ans, sep='\n')