n, k = gets.split.map(&:to_i)

max = 0
w = []
n.times{
  m = gets.to_i
  w.push(m)
  max = m if max < m
}

sum = w.inject(&:+)

p = (sum / k.to_f).ceil
p = max if max > p

loop do
  tmp = w.clone
  rest = p
  car = 0
  flag = 1
  loop do
    it = tmp.shift
    if rest - it >= 0 then
      rest -= it
    else
      # next car
      rest = p - it
      car += 1
      if car >= k then
        p += 1
        flag = 0
        break
      end
    end
    break if tmp.size == 0
  end
  break if flag == 1
end
puts p