n,k=int(eval(input())),int(eval(input()));x=list(map(int,input().split()))

print((sum([min(i,j) for i,j in zip([abs(i*2) for i in x],[abs((i-k)*2) for i in x])])))
n,k=int(eval(input())),int(eval(input()));print((sum([min(abs(i*2),abs((i-k)*2)) for i in list(map(int,input().split()))])))
n, k = int(eval(input())), int(eval(input()))
x = list(map(int, input().split()))
print(
    (
        sum(
            [
                min(i, j)
                for i, j in zip([abs(i * 2) for i in x], [abs((i - k) * 2) for i in x])
            ]
        )
    )
)

n, k = int(eval(input())), int(eval(input()))
print(
    (sum([min(abs(i * 2), abs((i - k) * 2)) for i in list(map(int, input().split()))]))
)

-x = list(map(int, input().split())) -    ( -        sum( -            [ -                min(i, j) -                for i, j in zip([abs(i * 2) for i in x], [abs((i - k) * 2) for i in x]) -            ] -        ) -    ) +    (sum([min(abs(i * 2), abs((i - k) * 2)) for i in list(map(int, input().split()))]))