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

inf :: Int
inf = 200000000

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