module Main where

import Control.Applicative
import Control.Monad
import Data.Array.Unboxed
import Data.Array.IArray

main :: IO ()
main = do
    [n, k] <- fmap read . words <$> getLine :: IO [Int]
    xs <- fmap read . words <$> getLine :: IO [Int]
    let ary = listArray (0, n-1) xs :: UArray Int Int
    let f i = let a = ary ! i
                  b = ary ! (i + (k-1))
                  c = min (abs a) (abs b)
                  d = abs (b - a)
              in c + d
    let b = foldr (\i acc -> min (f i) acc) maxBound [0 .. n-k]
    print b