def needed_truck(capacity, weights)
  t = 1
  c = capacity
  weights.each do |w|
    if w <= c
      c -= w
    else
      t += 1
      c = capacity - w
    end
  end
  t
end

n, k = gets.split.map(&:to_i)
weights = (1..n).map { gets.to_i }
min, max = weights.max, weights.inject(:+)
p (min..max).bsearch {|capacity| needed_truck(capacity, weights) <= k }
