n, k = gets.split.map(&:to_i)
w = 1.upto(n).map{gets.to_i}
min = w.max

loop do
  a = 1
  t = 0
  sub_min = 99999999
  for x in w do
    if t + x > min
      sub_min = t + x if sub_min > t + x
      t = x
      a += 1
      break if a > k
    else
      t += x
    end
  end
  break if a <= k
  min = sub_min
end

puts min