n,k = gets.split.map(&:to_i)
w = []
(n).times do |i|
  w[i] = gets.to_i
end
m = w.max
ans = (m..n*m).bsearch{|i|
  count = 1
  rest = i
  for wi in w do
    if rest >= wi
      rest -= wi
    else
      count += 1
      rest = i-wi
    end
  end
  k >= count
}
printf("%d\n",ans)
