import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B

main=B.interact$B.pack.show.f.unfoldr(B.readInt.B.dropWhile isSpace)
f (n:k:xs) = a
    where
        (mxs,pxs) = span (<0) xs
        ms = drop (max 0 (length mxs - k)) $ map (0-) mxs
        lm = length ms
        ams = zip (ms++[0]) $ drop (max 0 (k-lm-1)) pxs
        a = minimum $ concatMap (\(a,b)->[a*2+b,a+b*2]) ams