n, m = list(map(int, input().split()))

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

s = sum(ps)

ls = []

for p in ps:

    prev = p

    while p > 0:

        p //= 2

        ls.append(prev - p)

        prev = p

ls.sort(reverse=True)

print((s - sum(ls[:m])))
import heapq



n, m = list(map(int, input().split()))

ps = list([-x for x in list(map(int, input().split()))])

heapq.heapify(ps)



for _ in range(m):

    p = -heapq.heappop(ps)

    heapq.heappush(ps, -(p // 2))

print((-sum(ps)))
n, m = list(map(int, input().split()))
ps = list(map(int, input().split()))
s = sum(ps)
ls = []
for p in ps:
    prev = p
    while p > 0:
        p //= 2
        ls.append(prev - p)
        prev = p
ls.sort(reverse=True)
print((s - sum(ls[:m])))

import heapq

n, m = list(map(int, input().split()))
ps = list([-x for x in list(map(int, input().split()))])
heapq.heapify(ps)
for _ in range(m):
    p = -heapq.heappop(ps)
    heapq.heappush(ps, -(p // 2))
print((-sum(ps)))

+import heapq + -ps = list(map(int, input().split())) -s = sum(ps) -ls = [] -for p in ps: -    prev = p -    while p > 0: -        p //= 2 -        ls.append(prev - p) -        prev = p -ls.sort(reverse=True) -print((s - sum(ls[:m]))) +ps = list([-x for x in list(map(int, input().split()))]) +heapq.heapify(ps) +for _ in range(m): +    p = -heapq.heappop(ps) +    heapq.heappush(ps, -(p // 2)) +print((-sum(ps)))