import sys def main(): N, K = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) if K == 0: print(0) return total = sum(A) if K == 1: print(total) return low = 0 high = total best = 0 B = A + A while low <= high: mid = (low + high) // 2 if mid == 0: best = max(best, 0) low = mid + 1 continue if total < K * mid: high = mid - 1 continue found = False for i in range(N): current = 0 count = 0 j = i while j < i + N: current += B[j] if current >= mid: count += 1 current = 0 if count >= K: break j += 1 if count >= K: found = True break if found: best = mid low = mid + 1 else: high = mid - 1 print(best) if __name__ == "__main__": main()