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

q=S[-1]
i=0
loop{
  l=0
  k=0
  while W[l]
    sum=0
    while W[l] && sum+W[l]<=q
      sum+=W[l]
      l+=1
    end
    k+=1
  end
  p(q)&&exit if k<=K
  q+=S[0]
  i+=1
}