import scala.io.StdIn.{readLong,readLine}

object Main {
  def main(args:Array[String]) = {
    val n = readLine.split(" ").map(_.toInt)
    val a = (0 until n(0)).map(_=>readLong).toArray
    val l = a.max
    val r = 100000*100000

    def load(i:Int, j:Int, s:Long, p:Long):Boolean = {
      if(i==n(0)) true
      else if(j==n(1)) false
      else {
        if(s + a(i) <= p) load(i+1,j,s+a(i),p) else load(i,j+1,0,p)
      }
    }

    def scan(left:Long, right:Long):Long = {
      if(left<right) {
        val mid = (left+right)/2
        if(load(0,0,0,mid)) scan(left,mid)
        else scan(mid+1, right)
      } else right
    }

    println(scan(l,r))
  }
}