n = int(eval(input()))

k = int(eval(input()))

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

a = 0

b = 0

c = 0



for i in range(n):

    a = x[i] * 2

    b = abs(x[i] - k) * 2

    c += min(a,b)

    

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

k = int(eval(input()))

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

ans = 0

for i in range(n):

    a = x[i] * 2

    b = abs(x[i] - k) * 2

    ans += min(a,b)

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

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

-a = 0 -b = 0 -c = 0 +ans = 0 -    c += min(a, b) -print(c) +    ans += min(a, b) +print(ans)