class Solution:
def maxKelements(self, nums: List[int], k: int) -> int:
q = [-x for x in nums]
heapify(q)
ans = 0
for _ in range(k):
x = heappop(q)
ans += -x
heappush(q, -((-x + 2) // 3))
return ans