def calcLoad(baggage, k)
  load = baggage.max
  while(1)
    count = 0
    index = 0
    k.times do
      tmp = 0
      while index < baggage.size && tmp + baggage[index] <= load
        tmp += baggage[index]
        index += 1
      end
    end
    return load if baggage.size <= index
    load += 1
  end
end

baggage = []
n, k = gets.chomp.split(' ').map(&:to_i)
n.times do
  baggage.push(gets.to_i)
end
puts calcLoad(baggage, k)