n, k = gets.split.map(&:to_i)

ws = $stdin.readlines.map(&:to_i)

check = lambda do |p|
  i = 0
  0.upto(k - 1) do |j|
    s = 0
    while s + ws[i] <= p
      s += ws[i]
      i += 1
      return n if i == n
    end
  end
  return i
end

left = 0
right = 100000 * 10000

while right - left > 1
  mid = (left + right) / 2
  v = check.call(mid)
  if v >= n
    right = mid
  else
    left = mid
  end
end

puts right