import Control.Monad
import Data.List
main = do
  [_,k] <- map read . words <$> getLine
  xs <- map read . words <$> getLine
  print $ minimum (map move $ takeKs k xs)
 
takeKs :: Int -> [Int] -> [[Int]]
takeKs k xs | length xs >= k = take k xs : takeKs k (tail xs)
takeKs _ _  = []

move :: [Int] -> Int
move xs = (min nsum psum) * 2 + max nsum psum
  where
    (n,p) = break (> 0) xs
    nsum = if null n then 0 else abs $ minimum n
    psum = if null p then 0 else maximum p