let rec firstNth list n = match list with
  | [] -> []
  | _ when n = 0 -> []
  | x::rest -> x::(firstNth rest (n-1))


let solve_oneway n k list fil =
  let dists = List.filter fil @@ List.map (fun x -> (x, abs x)) list in
  if List.length dists < k then 10000000000 else
    begin
      let sorted = firstNth (List.sort (fun x y -> if (snd x) < (snd y) then -1 else 1) dists) k in
      let maxL = List.fold_left (fun acc x -> max acc (abs (fst x))) 0 sorted in
      maxL
    end

let solve n k list =
  let dists = List.map (fun x -> (x, abs x)) list in
  let sorted = firstNth (List.sort (fun x y -> if (snd x) < (snd y) then -1 else 1) dists) k in
  let maxL = List.fold_left (fun acc x -> max acc (fst x)) 0 sorted and
      minL = List.fold_left (fun acc x -> min acc (fst x)) 0 sorted in
  let bway = maxL + (abs minL) + (min maxL (abs minL)) and
      neg = solve_oneway n k list (fun x -> (fst x) <= 0) and
      pos = solve_oneway n k list (fun x -> (fst x) >= 0) in
  min (min bway neg) pos

let read_list_of_int () =
  let rec read_list_of_int_inner lst =
    try let ans = (Scanf.scanf "%d " (fun x->x)) in
        read_list_of_int_inner (ans::lst)
    with End_of_file ->
      List.rev lst
  in
  read_list_of_int_inner []

let () =
  let n, k = (Scanf.scanf "%d %d\n" (fun x y -> x,y)) in
  let list = read_list_of_int () in
  let ans = solve n k list in
  Printf.printf "%d\n" ans;
;;
