object Main extends App {

  // refs 
  // http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2298030#1
  //
  
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt 
  val list = List.fill(n)(sc.nextLong) 

  //println(list.size)
  
  def judge(i: Int, j: Int, c: Long, p: Long): Boolean = {
    if(i == n) true
    else if(j == k) false
    else {
      if(c + list(i) <= p) judge(i+1, j, c+list(i), p) else judge(i,j+1,0,p)
    }
  }
  
  def scan(left:Long, right:Long):Long = {
    if(left<right) {
      val mid = (left+right)/2
      if(judge(0,0,0,mid)) scan(left,mid)
      else scan(mid+1, right)
    } else right
  }

  val l = list.max
  val r = 100000 * 10000
  println(scan(l, r))

}
