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

N_MAX = K_MAX = 100000
W_MAX = 10000

left = 0
right = N_MAX * W_MAX
mid = nil

load_buggage = -> (p) do
  i = 0
  0.step(k-1) do |j|
    s = 0
    #STDERR.puts "  kj=#{j}"
    while s + w[i] <= p
      s += w[i]
      #STDERR.puts "    #{i}: w[#{i}]=#{w[i]}, s=#{s}"
      i += 1
      break if i == n
    end
    break if i == n
  end
  puts "load: #{i}"
  i
end

until (right - left) == 1 do
  mid = (left + right) / 2
  #STDERR.puts "L=#{left}, M=#{mid}, R=#{right}"
  v = load_buggage.(mid)
  if (v >= n)
    right = mid
  else
    left = mid
  end
end

puts right
