object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt 
  val list = List.fill(n)(sc.nextInt) 

  def judge(p: Long): Long = {
    var i = 0
    var j = 0
    while(j < k){
      var c = 0
      while(i < n && c + list(i) <= p){
        c += list(i)
        i += 1
      }
      j = if(i >= n) k else j + 1
    }
    i
  }
  
  var left: Long = 0
  var right: Long = 100000 * 10000
  var mid: Long  = 0

  while(right - left > 1){
    mid = (left + right) / 2
    val v = judge(mid)
    if(v >= n){
      right = mid
    } else {
      left = mid
    }
  }
  
  println(right)

}
