main = do 
 n <- (read::String->Double) <$> getLine
 k <- (read::String->Double) <$> getLine
 xx <- map (read::String->Double) .words <$> getLine
 let ikichi = k / 2 
 print .sum .map (\x->ceiling $ 2*(ikichi-abs (x-ikichi))) $ xx

 {-
 let diff = abs(x - ikichi)
 let dist = ikichi - diff
 -}