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