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

loop do
  a = 1
  t = 0
  w.each{|x|
    if t + x > min
      t = x
      a += 1
    else
      t += x
    end
  }
  break if a <= k
  min += 1
end

puts min