n, k = map(int, input().split()) A = list(map(int, input().split())) def check(M): if M == 0: return True sum_total = sum(A) if sum_total < k * M: return False current_sum = 0 count = 0 for num in A: current_sum += num if current_sum >= M: count += 1 current_sum = 0 if count >= k: return True return count >= k sum_total = sum(A) low = 0 high = sum_total // k ans = 0 while low <= high: mid = (low + high) // 2 if check(mid): ans = mid low = mid + 1 else: high = mid - 1 print(ans)