import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

getInts :: IO[Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  [n,k] <- map read . words <$> getLine
  xn <- getInts
  print $ minimum $ map (\x -> let (l,r) = (head x,last x) in min (abs(l)+(r-l)) (abs(r)+(r-l)) ) [take k (drop i xn)| i <- [0..n-k]]

