n, k = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) low = 1 high = total ans = 0 while low <= high: mid = (low + high) // 2 if total < k * mid: high = mid - 1 continue 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)