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(&:+)

if k == 1 then
  p = sum
elsif k == n then
  p = max
else
  left = max
  right = 100000 * 100000
  # Binary search
  while left <= right
    middle = (left + right)/2
    i = 0
    on_truck = 0
    truck = 1
    while i < n
      on_truck += w[i]
      if middle < on_truck then
        truck += 1
        break if k < truck
        on_truck = w[i]
      end
      i += 1
    end
    p = middle if truck <= k

    if k < truck then
      left = middle + 1
    else
      right = middle - 1
    end
  end
end
puts p