def can_partition_with_max_sum(arr, N, K, max_sum): current_sum = 0 sections = 0 for i in range(2 * N): # we iterate through the doubled array current_sum += arr[i % N] if current_sum > max_sum: sections += 1 current_sum = arr[i % N] if sections >= K: return False return True def minimize_max_section_value(N, K, arr): left = max(arr) right = sum(arr) while left < right: mid = (left + right) // 2 if can_partition_with_max_sum(arr, N, K, mid): right = mid else: left = mid + 1 return left # Read input N, K = map(int, input().strip().split()) arr = list(map(int, input().strip().split())) # Output the minimized maximum value of the sections print(minimize_max_section_value(N, K, arr))