N,K=gets.split.map &:to_i
W=$<.map &:to_i
M=W.max
L=W.size

(M..999).map{|pp|
  l=0
  k=0
  while W[l]
    sum=0
    while W[l] && sum+W[l]<=pp
      sum+=W[l]
      l+=1
    end
    k+=1
  end
  p(pp)&&exit if k<=K
}