n, k = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) def is_possible(x): if total < x * k: return False current_sum = 0 count = 0 for num in a: current_sum += num if current_sum >= x: count += 1 current_sum = 0 if count >= k: return True return False low = 0 high = total // k answer = 0 while low <= high: mid = (low + high) // 2 if is_possible(mid): answer = mid low = mid + 1 else: high = mid - 1 print(answer)