N, M= list(map(int, input().split()))

A = list(map(int, input().split()))



A.sort()

l = -1

r = A[-1] + 1





while r - l > 1:

    m = (r + l) // 2

    mc = 0

    a = 0

    for i in range(N):

        s = A[i]

        while m < s:

            s //= 2

            mc += 1

        a += s

    if mc <= M:

        r = m

        ans = a - (M - mc) * ((m // 2) + m % 2)

    else:

        l = m 

            

print(ans)
import heapq



N, M= list(map(int, input().split()))

A = list(map(int, input().split()))



for i in range(N):

    A[i] *= -1

heapq.heapify(A)





for i in range(M):

    b = heapq.heappop(A) * (-1)

    heapq.heappush(A, (b // 2) * (-1))

    



print((sum(A) * -1))
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
l = -1
r = A[-1] + 1
while r - l > 1:
    m = (r + l) // 2
    mc = 0
    a = 0
    for i in range(N):
        s = A[i]
        while m < s:
            s //= 2
            mc += 1
        a += s
    if mc <= M:
        r = m
        ans = a - (M - mc) * ((m // 2) + m % 2)
    else:
        l = m
print(ans)

import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
    A[i] *= -1
heapq.heapify(A)
for i in range(M):
    b = heapq.heappop(A) * (-1)
    heapq.heappush(A, (b // 2) * (-1))
print((sum(A) * -1))

+import heapq + -A.sort() -l = -1 -r = A[-1] + 1 -while r - l > 1: -    m = (r + l) // 2 -    mc = 0 -    a = 0 -    for i in range(N): -        s = A[i] -        while m < s: -            s //= 2 -            mc += 1 -        a += s -    if mc <= M: -        r = m -        ans = a - (M - mc) * ((m // 2) + m % 2) -    else: -        l = m -print(ans) +for i in range(N): +    A[i] *= -1 +heapq.heapify(A) +for i in range(M): +    b = heapq.heappop(A) * (-1) +    heapq.heappush(A, (b // 2) * (-1)) +print((sum(A) * -1))