let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; k] -> begin
      let a = Array.init n (fun _ -> read_int ()) in
      let check p =
        let rec doit i j s =
          if i = n then n
          else if j >= k then i
          else
            let x = s + a.(i) in
            if x > p then doit i (j + 1) 0
            else doit (i + 1) j x
        in
        doit 0 0 0
      in
      let rec bin_search l r =
        if r < l then l
        else
          let m = (l + r) / 2 in
          if check m >= n then bin_search l (m - 1)
          else bin_search (m + 1) r
      in
      Printf.printf "%d\n" (bin_search 0 (100000 * 10000))
    end
  | _ -> exit 1