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

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

main = do
  [n,k] <- map read . words <$> getLine
  xn <- VU.fromList <$> getInts
  print $ foldl (\acc i -> let (l,r) = (xn VU.! i,xn VU.! (i+k-1)) in minimum [acc , abs (l)+abs(r-l),abs(r) + abs(r-l)]) 999999 [0..n-k]
