n = int(eval(input()))

k = int(eval(input()))

x = list(map(int, input().split()))

ans = 0

for i in x:

    ans += min(abs(i-0),abs(i-k))*2

print(ans)
n = int(eval(input()))

k = int(eval(input()))

xl = list(map(int, input().split()))

ans = 0

for i in xl:

    ans+= min(abs(i-0), abs(k-i))*2

print(ans)
n = int(eval(input()))
k = int(eval(input()))
x = list(map(int, input().split()))
ans = 0
for i in x:
    ans += min(abs(i - 0), abs(i - k)) * 2
print(ans)

n = int(eval(input()))
k = int(eval(input()))
xl = list(map(int, input().split()))
ans = 0
for i in xl:
    ans += min(abs(i - 0), abs(k - i)) * 2
print(ans)

-x = list(map(int, input().split())) +xl = list(map(int, input().split())) -for i in x: -    ans += min(abs(i - 0), abs(i - k)) * 2 +for i in xl: +    ans += min(abs(i - 0), abs(k - i)) * 2