CodeEff/ECCO huggingface dataset:
# Original solution
import heapq
import math
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

"""
a = [1,7,3,5,4]

#heapify
#配列a = [1,7,3,5,4]をheapにする
heapq._heapify_max(a)
print(a) #[7, 5, 3, 1, 4]

#heappop
#最大値の取り出し
print(_heappop_max(a)) #7
print(a) #[5, 4, 3, 1]

#heappush
#要素(2)の挿入
_heappush_max(a,2)
print(a) #[5, 4, 3, 1, 2]

#最大値の取り出し
print(_heappop_max(a)) #5
"""

N, M = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = a[:N]
heapq._heapify_max(b)

okaiage = []
heapq._heapify_max(okaiage)
_heappush_max(okaiage, _heappop_max(b)/2)

m = M - 1
for j in range(N-1):
    temp_oka = _heappop_max(okaiage)
    temp_a = _heappop_max(b)
    if m > 0:
        if temp_a > temp_oka:
            _heappush_max(okaiage, temp_a/2)
            _heappush_max(okaiage, temp_oka)
        else:
            _heappush_max(okaiage, temp_a)
            _heappush_max(okaiage, temp_oka/2)
    else:
        _heappush_max(okaiage, temp_a)
        _heappush_max(okaiage, temp_oka)
    m -= 1
if m > 0:
    for i in range(m):
        temp_oka = _heappop_max(okaiage) / 2
        _heappush_max(okaiage, temp_oka)
okaiage_kiri = [int(math.floor(_heappop_max(okaiage))) for i in range(N)]
print((sum(okaiage_kiri)))


# Optimized solution
import heapq
import math
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

"""
a = [1,7,3,5,4]

#heapify
#配列a = [1,7,3,5,4]をheapにする
heapq._heapify_max(a)
print(a) #[7, 5, 3, 1, 4]

#heappop
#最大値の取り出し
print(_heappop_max(a)) #7
print(a) #[5, 4, 3, 1]

#heappush
#要素(2)の挿入
_heappush_max(a,2)
print(a) #[5, 4, 3, 1, 2]

#最大値の取り出し
print(_heappop_max(a)) #5
"""

N, M = list(map(int, input().split()))
a = [int(i) for i in input().split()]
heapq._heapify_max(a)

for j in range(M):
    _heappush_max(a, _heappop_max(a)//2)
print((sum(a)))
# Original solution
import heapq
import math
#これを加える！！！！
def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

"""
a = [1,7,3,5,4]

#heapify
#配列a = [1,7,3,5,4]をheapにする
heapq._heapify_max(a)
print(a) #[7, 5, 3, 1, 4]

#heappop
#最大値の取り出し
print(_heappop_max(a)) #7
print(a) #[5, 4, 3, 1]

#heappush
#要素(2)の挿入
_heappush_max(a,2)
print(a) #[5, 4, 3, 1, 2]

#最大値の取り出し
print(_heappop_max(a)) #5
"""

N, M = list(map(int, input().split()))
a = [int(i) for i in input().split()]
heapq._heapify_max(a)

for j in range(M):
    _heappush_max(a, _heappop_max(a)//2)
print((sum(a)))


# Optimized solution
import heapq

n, m = list(map(int, input().split()))
a = list([int(x)*(-1) for x in input().split()])
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print((-sum(a)))
# Original solution
import heapq
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
x.sort(reverse=True)
heapq.heapify(x)
ans=0
for i in range(m):
    y=heapq.nlargest(1,x)[0]
    x.remove(y)
    x.append(y//2)
for j in range(n):
    ans+=x[j]
print(ans)

# Optimized solution
import heapq
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
for k in range(n):
    x[k]-=2*x[k]
heapq.heapify(x)
ans=0
for i in range(m):
    maxvalue=heapq.heappop(x)*(-1)
    heapq.heappush(x,(maxvalue//2)*(-1))
ans=-1*sum(x)
print(ans)
# Original solution
import bisect
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
for i in range(M):
  B = A.pop()
  bisect.insort_right(A,B//2)
print((sum(A)))

# Optimized solution
N,M = list(map(int,input().split()))
A = list([int(x)*(-1) for x in input().split()])
import heapq
heapq.heapify(A)
for i in range(M):
  B = heapq.heappop(A)
  heapq.heappush(A,-1*((-B)//2))
print((-sum(A)))
# Original solution
from heapq import*
n,m,*a=[-int(i)for i in open(0).read().split()]
heapify(a)
while m:heappush(a,0--heappop(a)//2);m+=1
print((-sum(a)))

# Optimized solution
def main():
  from heapq import heapify,heappush,heappop
  n,m,*a=[-int(i)for i in open(0).read().split()]
  heapify(a)
  for _ in range(-m):heappush(a,0--heappop(a)//2)
  print((-sum(a)))
main()
# Original solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    a[n-1] = a[n-1] // 2
    a.sort()
print((sum(a)))

# Optimized solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
    for i in range(m):
        a[0] = a[0] // 2
    print((sum(a)))
    exit()

a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    num = len([1 for x in a[:n-1] if x > a[n-1]])
    hoge = min(m-i, num)
    for j in range(hoge):
        a[n-2-j] = a[n-2-j] // 2
    i += hoge
    a.sort()

print((sum(a)))
# Original solution
#S = input()
N,M = list(map(int,input().split()))
A_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]

for i in range(M):
    A_list.sort(reverse=True)
    A_list[0] = A_list[0]//2
print((sum(A_list)))

# Optimized solution
from heapq import heappush, heappop,heapify
N,M = list(map(int,input().split()))


A_list = list([-int(a) for a in input().split()])
#print(A_list)
heapify(A_list)
#print(-heappop(A_list))
for i in range(M):
    tmp = -heappop(A_list)//2
    heappush(A_list,-tmp)
print((-sum(A_list)))

'''
3 3 
8 6 5
4 4
8 7 6 5 
10 6
10 7 6 5 8 9 10 11 12 13
'''
# Original solution
N,M=list(map(int,input().split()))
A=sorted(list(map(float,input().split())),reverse=True)
for i in range(M):
    A[0]=A[0]/2
    A=sorted(A,reverse=True)
A=[int(a) for a in A]
print((sum(A)))

# Optimized solution
import heapq
N,M=list(map(int,input().split()))
hq=list(map(float,input().split()))
hq=[-n for n in hq]
heapq.heapify(hq)
for i in range(M):
    heapq.heappush(hq,heapq.heappop(hq)/2)
hq=[int(a) for a in hq]
print((-sum(hq)))
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(M):
    A = sorted(A)
    A[-1] = A[-1] // 2

print((sum(A)))

# Optimized solution
import heapq

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

for i in range(len(A)):
    A[i] *= -1

heapq.heapify(A)
for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, (-x//2)*(-1))

print((-sum(A)))
# Original solution
n, m = list(map(int, input().split()))
a_list = list(map(int, input().split()))

a_list.sort(reverse=True)
swapped = False
while m > 0:
    a_list[0] = a_list[0] // 2
    m -= 1
    if (n > 1) and (a_list[0] < a_list[1]) and not swapped:
        temp = a_list[0]
        a_list[0] = a_list[1]
        a_list[1] = temp
        swapped = True
    else:
        a_list.sort(reverse=True)
        swapped = False

cost_sum = 0
for a in a_list:
    cost_sum += a

print(cost_sum)


# Optimized solution
from heapq import heappush, heappop

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

hqueue = []
for a in a_list:
    heappush(hqueue, -a)

for i in range(m):
    max_item = -(-heappop(hqueue) // 2)
    heappush(hqueue, max_item)

cost = 0
for i in range(n):
    cost += -heappop(hqueue)

print(cost)
# Original solution
n,m=list(map(int,input().split()))#n:num m:ticket
a=[int(_) for _ in input().split()]
for i in range(m):
	a[a.index(max(a))]=max(a)//2
print((sum(a)))

# Optimized solution
from heapq import heapify,heappop,heappush
n,m=list(map(int,input().split()))#n:num m:ticket
a=[-int(_) for _ in input().split()]
heapify(a)
for i in range(m):
	num=heappop(a)*-1
	heappush(a,(num//2)*-1)
print((sum(a)*-1))
# Original solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
while m > 0:
    M = max(a)
    tmp = a.index(M)
    a[tmp] = a[tmp] // 2
    m -= 1
print((sum(a)))


# Optimized solution
import heapq
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))

pq = []
for a in A:
    heapq.heappush(pq, -a)#'-'にすることで最大値を考えることができる！
#print(pq)
for _ in range(m):
    a = (-heapq.heappop(pq)) // 2
    heapq.heappush(pq, -a)
print((-sum(pq)))
# Original solution
import math
n, m = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(m):
    a[a.index(max(a))] = a[a.index(max(a))]/2
for i in range(len(a)):
    a[i] = math.floor(a[i])
print((sum(a)))

# Optimized solution
from heapq import heappop, heappush, heapify

N, M = list(map(int,input().split()))
A = list(map(int, input().split()))
A = list([x*(-1) for x in A])
heapify(A)

for i in range(M):
    temp = int(heappop(A)/2)
    heappush(A, temp)

print((-sum(A)))
# Original solution
import sys
n,m = list(map(int,input().split()))
lst_a = list(map(int,input().split()))
lst_a.sort(reverse=True)
temp = 0
ans = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print((lst_a[0]))
    sys.exit()
for i in range(m):
    if lst_a[0] >= lst_a[1]:
        lst_a[0] //= 2
    else:
        lst_a[1] //= 2
        lst_a.sort(reverse=True)
print((sum(lst_a)))


# Optimized solution
import sys
n,m = list(map(int,input().split()))
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
fin = 0
loop = 0
debug = 0
temp2 = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print((lst_a[0]))
    sys.exit()
while debug < 10:
    loop = 0
    #temp2 = temp
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            #print(lst_a)
            print((sum(lst_a)))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        
        
"""        if lst_a[loop] >= max(lst_a[loop + 1],temp):
            lst_a[loop] //= 2
            temp = max(lst_a[loop],lst_a[loop+1])
            cnt += 1
            if cnt == m:
                print(sum(lst_a))
                sys.exit()
            if temp > lst_a[loop + 1]:
                break
            
            
        loop += 1
    
    #debug += 1
print(lst_a[99999])
# print(temp)
# print(cnt)
# print(lst_a)
# print(sum(lst_a))
"""
# Original solution
import math
import copy
from queue import Queue

#n = int(input())
n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(m) :
    s[s.index(max(s))] = math.floor(max(s)/2)

print((sum(s)))

# Optimized solution
import math
import copy
from queue import Queue
import heapq

#n = int(input())
n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
#s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

s = list([x*(-1) for x in s])
heapq.heapify(s)

for i in range(m) :
    heapq.heappush(s, math.ceil(heapq.heappop(s)/2))

print((sum(s)*(-1)))
# Original solution
def insertion_sort(array):
    n = array[0]
    for i in range(1, len(array)):
        tmp = array[i]
        if array[i] <= n :
            break
        else:
            array[i-1] = tmp
            array[i] = n
            
    return array

n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()]
a.sort(reverse=True)
for i in range(m):
    down = a[0]
    a.remove(down)
    a.insert(0,down//2)
    a = insertion_sort(a)
    
print((sum(a)))






# Optimized solution
n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()]
b = []

a.sort(reverse=True)

for i in range(m):
    if i == 0:
        down = a[0]
        a.remove(down)
        b.append(down//2)
    else:
        if a != [] and a[0] >= b[0]:
            down = a[0]
            a.remove(down)
        else:
            down = b[0]
            b.remove(down)
        b.append(down//2)
    
print((sum(a)+sum(b)))
# Original solution
n, m = list(map(int, input().split()))
*a, = sorted(map(int, input().split()), key=lambda x: -x)
for i in range(m):
    tmp = a.pop(0)
    tmp //= 2
    if not a:
        a.append(tmp)
    for j in range(min(len(a), m-i)):
        if tmp > a[j]:
            a.insert(j, tmp)
            break
    else:
        a.append(tmp)

print((sum(a)))

# Optimized solution
import heapq, math

n, m = list(map(int, input().split()))
*a, = [-int(x) for x in input().split()]
heapq.heapify(a)

for i in range(m):
    tmp = heapq.heappop(a)
    tmp = math.ceil(tmp / 2)
    heapq.heappush(a, tmp)

print((-sum(a)))
# Original solution
import bisect
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

A.sort()

for i in range(M):
        tmp = A.pop(-1) // 2
        index = bisect.bisect_left(A, tmp)
        A.insert(index, tmp)


print((sum(A)))

# Optimized solution

import heapq
N, M = list(map(int, input().split()))
A = list([int(x) * (-1) for x in input().split()])

heapq.heapify(A)

for i in range(M):
        tmp = int(heapq.heappop(A) / 2)
        heapq.heappush(A, tmp)

print((sum(A) * -1))
# Original solution

import heapq
N, M = list(map(int, input().split()))
A = list([int(x) * (-1) for x in input().split()])

heapq.heapify(A)

for i in range(M):
        tmp = int(heapq.heappop(A) / 2)
        heapq.heappush(A, tmp)

print((sum(A) * -1))

# Optimized solution
import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list([x * -1 for x in A])
heapq.heapify(A)
for i in range(M):
    heapq.heappush(A, (heapq.heappop(A) + 1) // 2)
print((sum(A) * -1))
# Original solution
import bisect
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()
while M != 0:
    x = bisect.bisect_left(A,A[-1]/2)
    if N-x <= M:
        M -= N-x
        for i in range(x,N):
            A[i] = A[i]/2
        A.sort()
    else:
        for i in range(N-M,N):
            A[i] = A[i]/2
        M = 0
        A.sort()

print((sum(map(int,A))))


# Optimized solution
#二分探索を使った解法
import bisect
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()
while M != 0:
    x = bisect.bisect_left(A,A[-1]//2)
    if N-x <= M:
        M -= N-x
        for i in range(x,N):
            A[i] = A[i]//2
        A.sort()
    else:
        for i in range(N-M,N):
            A[i] = A[i]//2
        M = 0
        A.sort()

print((sum(A)))
# Original solution
#Priority Queueを使った解法
import heapq

N,M = list(map(int,input().split()))
A = list([(-1)*int(x) for x in input().split()])

heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))

print((-sum(A)))

# Optimized solution
import heapq

n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a = list([-x for x in a])
heapq.heapify(a)

#print(a)

for i in range(m):
    x = heapq.heappop(a)
    x = (-x)//2
    heapq.heappush(a,-x)
print((-sum(a)))
# Original solution
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(m):
    A[A.index(max(A))] /= 2
print((sum([int(a) for a in A])))

# Optimized solution
import heapq
n, m = list(map(int, input().split()))
A = list([-x for x in list(map(int, input().split()))])
heapq.heapify(A)
for i in range(m):
    mx = heapq.heappop(A)
    heapq.heappush(A,mx/2)
print((sum([int(-a) for a in A])))
# Original solution

import math

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

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

for i in range(M):
    max_A = max(A)
    A[A.index(max_A)] = math.floor((max_A) / 2)

print((sum(A)))


# Optimized solution

#優先度付きキュー
#値の追加 O(log|Q|)
#値の削除 O(log|Q|)
#最大値の取得 O(1)
#pythonでは 最小値のみしか取得できないため事前に全要素に-1をかけておき最後のまた-1かける

import math
import heapq

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

#各要素を-1倍
A = list(map(int,input().split()))
A = list([x*-1 for x in A])
heapq.heapify(A)

for i in range(M):
    max_A = heapq.heappop(A)
    max_A = max_A * -1
    heapq.heappush(A,-1* (math.floor((max_A) / 2)) )

print((-1 * sum(A)))
# Original solution
#coding:utf-8

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

for m in range(M):
    A[A.index(max(A))] = max(A)/2
total = sum(map(int, A))

print(total)


# Optimized solution
#coding:utf-8

import heapq

N, M = list(map(int, input().split()))
invA = []
for a in map(int, input().split()):
    heapq.heappush(invA, -1*a)
for m in range(M):
    heapq.heappush(invA, heapq.heappop(invA)/2)
total = -1*sum(map(int, invA))

print(total)
# Original solution
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    for i in range(len(a)):
        a[i] = a[i] * - 1
    heapq.heapify(a)
    for i in range(m):
        p = heapq.heappop(a)
        p /= 2
        heapq.heappush(a, p)
    t = 0
    for i in range(len(a)):
        t += int(a[i])
    print((-t))


if __name__ == '__main__':
    slove()


# Optimized solution
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = [- i for i in list(map(int, input().rstrip('\n').split()))]
    heapq.heapify(a)
    for i in range(m):
        heapq.heappush(a, -(-heapq.heappop(a) // 2))
    print((-sum(a)))


if __name__ == '__main__':
    slove()
# Original solution
import heapq

n, m = list(map(int, input().split()))
a = list([int(x)*(-1) for x in input().split()])
heapq.heapify(a)

for i in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print((-sum(a)))

# Optimized solution
import heapq

n, m = list(map(int, input().split()))
a = list([int(x)*(-1) for x in input().split()])
heapq.heapify(a)

for i in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))
print((-sum(a)))
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
Asorted = sorted(A)
MM = 0
if M+1 >= N:
    MM = N
else:
    MM = M+1
Atop = [Asorted[N-i-1] for i in range(MM)]
for i in range(M):
    Atopmax = Atop.index(max(Atop))
    Atop[Atopmax] = Atop[Atopmax]//2
count = 0
for i in range(N-MM):
    count += Asorted[i]
count += sum(Atop)
print(count)

# Optimized solution
#標準入力
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
#heapqをimportして、Aの要素をすべてマイナスにしてheapify
import heapq
def minus(n):
    return -n
A = list(map(minus, A))
heapq.heapify(A)
#その最小値を出力して削除し、その半分を追加することをM回やる
for i in range(M):
    heapq.heappush(A, -(-heapq.heappop(A)//2))
#Aの要素を合計してminusして出力する
print((minus(sum(A))))
# Original solution
import heapq

def calc_minus(n):
    return n * (-1)

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

values_minus = []
for val1 in values:
    values_minus.append(calc_minus(val1))

for i in range(M):
    heapq.heapify(values_minus)
    tmp = heapq.heappop(values_minus)
    tmp_push = ((tmp * (-1)) // 2) * (-1)
    heapq.heappush(values_minus, tmp_push)

values_plus = []
for val2 in values_minus:
    values_plus.append(calc_minus(val2))

result = 0
for val3 in values_plus:
    result += val3

print(result)

# Optimized solution
import heapq

def calc_minus(n):
    return n * (-1)

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

values_minus = []
for val1 in values:
    values_minus.append(calc_minus(val1))

heapq.heapify(values_minus)

for i in range(M):
    tmp = heapq.heappop(values_minus)
    tmp_push = ((tmp * (-1)) // 2) * (-1)
    heapq.heappush(values_minus, tmp_push)

values_plus = []
for val2 in values_minus:
    values_plus.append(calc_minus(val2))

result = 0
for val3 in values_plus:
    result += val3

print(result)
# Original solution
from bisect import bisect_left
from math import floor


def p_d():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A.sort()

    for _ in range(M):
        x = A.pop() / 2

        i = bisect_left(A, x)

        A.insert(i, x)

    ans = 0

    for a in A:
        ans += floor(a)

    print(ans)


if __name__ == '__main__':
    p_d()


# Optimized solution
from heapq import heappop, heappush
from math import ceil, floor


def p_d():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    H = []

    for a in A:
        heappush(H, a * -1)

    for _ in range(M):
        x = heappop(H)

        heappush(H, ceil(x / 2))

    ans = 0

    for a in H:
        ans -= a

    print(ans)


if __name__ == '__main__':
    p_d()
# Original solution
from bisect import *
N,M = list(map(int,input().split()))
A = sorted(list(map(int,input().split())))

for m in range(M):
  A[-1]//=2
  A.insert(bisect_left(A,A[-1]),A[-1])
  A.pop()
  
print((sum(A)))

# Optimized solution
from heapq import *
N,M = list(map(int,input().split()))
A = list([-int(x) for x in input().split()])
heapify(A)

for m in range(M):
  heappush(A,int(heappop(A)/2))

print((-sum(A)))
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(M):
  index = A.index(max(A))
  A[index] = A[index] // 2
  
print((sum(A)))

# Optimized solution
import heapq
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [i*-1 for i in A]

heapq.heapify(A)

for i in range(M):
  kk = math.ceil(heapq.heappop(A) / 2)
  heapq.heappush(A, kk)

A = [i*-1 for i in A]

print((sum(A)))
# Original solution
class max_heap():
    def __init__(self,arr):
        self.array = arr
        self.build_heap()

    def heapify(self,i):
        left = 2 * i + 1
        right = 2 * i + 2
        length = len(self.array) - 1
        biggest = i
        
        if left <= length and self.array[i] < self.array[left]:
            biggest = left
        if right <= length and self.array[biggest] < self.array[right]:
            biggest = right
        if biggest != i:
            self.array[i], self.array[biggest] = self.array[biggest], self.array[i]
            self.heapify(biggest)

    def build_heap(self):
        for i in reversed(list(range(len(self.array)//2))):
            self.heapify(i)
            
    def heappop(self):
        self.array[0], self.array[-1] = self.array[-1], self.array[0]
        res = self.array.pop()
        self.heapify(0)
        return res
    
    def heappush(self,n):
        self.array.append(n)
        self.build_heap()

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
heap = max_heap(A)
for i in range(M):
    num = heap.heappop()//2
    heap.heappush(num)
print((sum(heap.array)))

# Optimized solution
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

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

# 最小値が返ってくるので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print((-sum(A)))