n, k = gets.split.map(&:to_i)
w = 1.upto(n).map{gets.to_i}
min = w.max
d = w.inject(:+) / k
min = d if min < d

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

puts min