def check(k, v)
  idx = 0 
  k.times.each do
    vv = v 
    while vv > 0 do
      vv -= @items[idx]
      next if vv < 0 
      return true if idx == @items.count-1
      idx += 1
    end 
  end 
  false
end

n, k = STDIN.gets.split(' ').map(&:to_i)
@items = n.times.map { STDIN.gets.to_i }

l, r = 0, @items.reduce(:+)

while r - l > 1 do
  m = (r + l) / 2 
  check(k, m) ? r = m : l = m 
end

puts r