n, k = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) left = 1 right = total // k answer = 0 while left <= right: mid = (left + right) // 2 if total < k * mid: right = mid - 1 continue current_sum = 0 count = 0 for num in a: current_sum += num if current_sum >= mid: count += 1 current_sum = 0 if count >= k: break if count >= k: answer = mid left = mid + 1 else: right = mid - 1 print(answer)