n, k = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) low = 0 high = total // k ans = 0 while low <= high: mid = (low + high) // 2 current = 0 count = 0 for num in a: current += num if current >= mid: count += 1 current = 0 if count >= k: ans = mid low = mid + 1 else: high = mid - 1 print(ans)