import Control.Monad
import Data.List

f :: Int -> Int -> Int
f l r
    | l < 0 && r < 0 = -l
    | l > 0 && r > 0 = r
    | otherwise = r - l + min r (-l)

main = do
    [n, k]  <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let l = take (n - k + 1) xs
    let r = drop (k - 1) xs
    print $ foldr min maxBound $ zipWith f l r
