n, k = gets.chomp.split(" ").map(&:to_i)
$w = n.times.map { gets.chomp.to_i }

def check(p)
  s = 1 
  tmp = 0
  $w.each do |i|
    if (tmp + i) >= p
      s += 1
      tmp = 0
    else
      tmp += i
    end
   end
  return s
end

a = ($w.max..10**9).bsearch do |x|
  k >= check(x) 
end
puts a

