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

N_MAX = K_MAX = 100000
W_MAX = 10000

l = 0
r = N_MAX * W_MAX

test = -> limit do
  i = 0
  0.step(k-1) do
    sum = 0
    while sum + W[i] <= limit
      sum += W[i]
      i += 1
      break if i == n
    end
    break if i == n
  end
  i+1
end

until (r - l) == 1 do
  m = (l + r) / 2
  v = test.(m)
  if v <= n
    l = m
  else
    r = m
  end
end

puts r
