import Data.Vector.Unboxed as V(fromList,(!),Vector)
import Control.Monad

inf :: Int
inf = 200000000

main :: IO ()
main = do
  [n,k] <- map read.words <$> getLine
  as <- V.fromList . map read.words <$> getLine :: IO (Vector Int)
  ls <- forM [0..n-k] $ \i -> return $ (min (abs $ as!i) $ (abs $ as!(i+k-1))) + (as!(i+k-1) - as!i)
  print $ minimum ls
