let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  for_fold 0 (n-k+1) 10101010101010 (fun s i ->
    let l, r = a.(i), a.(i+k-1) in
    if r <= 0 then min s (abs l)
    else if l >= 0 then min s r
    else min (r-2*l) (2*r-l) |> min s)
  |> Printf.printf "%d\n"