n=int(eval(input()))

k=int(eval(input()))

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

ans=0

for i in range(n):

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



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

k=int(eval(input()))

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

ans=0

for i in range(n):

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

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

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

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