
def f(weight, suspection, k, sum)
  yojo = suspection * k - sum
  i = 0
  j = 0
  while yojo >= 0 and j < k and i < weight.length
    temp = suspection
    while i < weight.length and temp - weight[i] >= 0
      temp -= weight[i]
      i += 1
    end
    j += 1
    yojo -= temp
  end
  return i != weight.length
end
n, k = gets.split(" ").map(&:to_i)
weight = []
n.times do
  weight << gets.to_i
end
sum = weight.inject(0){|s, item|s + item}
max = weight.max
max = sum / k if sum / k > max
while f(weight, max, k, sum)
  max += 1
end
puts max