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

# Optimized solution
import heapq
N, M = list(map(int, input().split()))
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    a = -heapq.heappop(A) // 2
    heapq.heappush(A, -a)
print((-sum(A)))
# Original solution
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(eval(input()))
def FLOAT(): return float(eval(input()))
MOD = 10**9+7

n,m = MAP()
a = MAP()

for i in range(m):
    idx = a.index(max(a))
    a[idx] = a[idx]//2

print((sum(a)))

# Optimized solution
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(eval(input()))
def FLOAT(): return float(eval(input()))
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]
heapify(a)
for i in range(m):
    tmp = -heappop(a)
    heappush(a,-(tmp//2))
print((-sum(a)))
# Original solution
N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)

for _ in range(M):
    A[0] = int(A[0]/2)
    A = sorted(A, reverse=True)

print((sum(A)))

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

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

#heapqは最小値しか取り出さないので-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)))
# Original solution
#!/usr/bin/env python3

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

for _ in range(M):
    a_list = sorted(a_list, reverse=True)
    a_list[0] = a_list[0] // 2

ans = sum(a_list)
print(ans)


# Optimized solution
#!/usr/bin/env python3
import heapq

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

# Pythonのheapqは最小値しかとれないので、負の値に変換して扱う
a_list = list([x * (-1) for x in a_list])
heapq.heapify(a_list)

for _ in range(M):
    max_value = -heapq.heappop(a_list)
    heapq.heappush(a_list, -(max_value // 2))

ans = -sum(a_list)
print(ans)
# Original solution
from bisect import bisect_right

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

for i in range(m):
  tmp = aa[-1]//2
  aa.pop()
  pos = bisect_right(aa,tmp)
  aa.insert(pos,tmp)
  
print((sum(aa)))  

# Optimized solution
# dequeにinsert追加されたのは 3.5 から
from heapq import heappop,heappush,heapify
n,m = list(map(int,input().split()))
aa = list(map(int,input().split()))
aa = list([-x for x in aa])

heapify(aa)
for i in range(m):
  tmp = heappop(aa)  
  heappush(aa,-(-tmp//2))

print((-sum(aa)))
# Original solution
n, m = list(map(int,input().split()))
A = list(map(int,input().split()))
A = [x * -1 for x in A]
A.sort()
import heapq
import bisect
heapq.heapify(A)
for _ in range(m):
    min_ = heapq.heappop(A)
    tmp = min_ * -1 // 2 * -1
    index = bisect.bisect_left(A, tmp)
    heapq.heappush(A,tmp)
print((sum(A) * -1))


# Optimized solution
n, m = list(map(int,input().split()))
A = [x * -1 for x in list(map(int,input().split()))]
import heapq
heapq.heapify(A)
for _ in range(m):
    min_ = heapq.heappop(A)
    tmp = min_ * -1 // 2 * -1
    heapq.heappush(A,tmp)
print((sum(A) * -1))
# Original solution
#!/usr/bin/env python3

from heapq import heapify, heappop, heappush

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

for i in range(m):
    max = -1* heappop(a)
    heappush(a, int(-1*max/2))  # 要素の挿入

a = [-1*item for item in a]
ans = sum(list(a))

print(ans)


# Optimized solution
#!/usr/bin/env python3

from heapq import heapify, heappop, heappush

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

heapify(a)

for i in range(m):
    min = heappop(a)
    heappush(a, (-1)*(-1*min//2)) # 要素の挿入

ans = -sum(a)

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

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

# Optimized solution
from heapq import heappop,heappush,heapify
n,m=list(map(int,input().split()))
A=[-i for i in list(map(int,input().split()))]
heapify(A)
for i in range(m):
	a=heappop(A)
	heappush(A,-(-a//2))
print((-sum(A)))
# Original solution
import heapq
n ,m = list(map(int,input().split()))
arr =list(map(int,input().split()))
for _ in range(m):
  j =int( heapq.nlargest(1,arr)[0])//2
  arr.remove(max(arr))
  arr.append(j)
print((sum(arr)))

# Optimized solution
from heapq import heappop, heappush, heapify
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
q = []
for x in a:
	heappush(q, -x)
for _ in range(m):
	l = heappop(q)
	heappush(q, -((-l)//2))
print((-sum(q)))
# Original solution
N, M = list(map(int, input().split()))
price = list(map(int, input().split()))
for i in range(M):
  price[price.index(max(price))] //= 2

print((sum(price)))

# Optimized solution
from heapq import heappop, heappush

N, M = list(map(int, input().split()))
price = list(map(int, input().split()))
he = []
for i in price:
  heappush(he, -i)
for i in range(M):
  max = heappop(he)
  heappush(he, -(-max//2))
print((-sum(he)))
# 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 _ in range(m):
    tmp = (heapq.heappop(a) * (-1)) // 2
    heapq.heappush(a, -tmp)
print((sum(a) * -1))


# Optimized solution
from heapq import heapify, heappop, heappush

N, M = list(map(int, input().split()))
A = []
for i in input().split():
    A.append(-int(i))
heapify(A)
for _ in range(M):
    a = -heappop(A)
    heappush(A, (a // 2) * -1)
# print('A', A)
ans = -sum(A)
print(ans)
# Original solution
import heapq
n,m=list(map(int,input().split()))
item=list(map(int,input().split()))
for i in range(n):item[i]=item[i]*-1
for i in range(m):
    heapq.heapify(item)
    a=heapq.heappop(item)
    heapq.heappush(item,((-1*a)//2)*-1)

print((sum(item)*-1))

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

print((-sum(item)))
# Original solution
import math

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

a = sorted(a)

for i in range(m):
    p = a.pop()
    p = math.floor(p/2)
    a.append(p)
    a = sorted(a)

print((sum(a)))

# Optimized solution
from heapq import heappop,heappush,heapify
import math

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

heapify(a)

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

ans = 0
for _ in range(n):
    p = heappop(a)
    ans += -p

print(ans)
# Original solution
from bisect import bisect_left

n,m = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])

for i in range(m):
    a.insert(bisect_left(a,a[n-1] // 2),a[n-1] // 2)
    a.pop(n)
print((sum(a)))


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

for _ in range(m):
    max = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-max//2))
print((-sum(a)))
# Original solution
N, M = list(map(int, input().split()))  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
for _ in range(M):
    tmp = A.index(max(A))
    A[tmp] = A[tmp] // 2
print((str(sum(A))))


# Optimized solution
N, M = list(map(int, input().split()))  # 品物の数、割引券の枚数
A = list(map(int, input().split()))  # 品物の値段
A.sort(reverse=True)
i = 0
for _ in range(M):
    A[i] = A[i] // 2
    if i <= N - 2 and A[i] < A[i + 1] and A[0] < A[i+1]:
        i += 1
    else:
        A.sort(reverse=True)
        i = 0
print((str(sum(A))))
# Original solution
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
if s[0]>=2:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
    if t[0]<t[1]:
      t.sort(reverse=True)
else:
  for j in range(s[1]):
    t[0]=math.floor(t[0]/2)
a=sum(t)
print(a)

# Optimized solution
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=0
c=0
d=s[1]
t.sort(reverse=True)
if s[0]==1:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
else:
  c=t[0]/2
  for j in range(s[1]):
    for l in range(s[0]):
      if d>0:
        if c<t[l]:
          t[l]=math.floor(t[l]/2)
          d=d-1
        else:
            t.sort(reverse=True)
            c=t[0]/2
            break
      else:
        break
e=sum(t)
print(e)
# Original solution
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    a_list = sorted(a_list, reverse=True)

    search_range = 1
    while m > 0:
        max_index = a_list[0:search_range].index(max(a_list[0:search_range]))
        a_list[max_index] = a_list[max_index] // 2
        m -= 1
        search_range += 1

    answer = sum(a_list)
    print(answer)


# Optimized solution
import heapq


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    q = []
    for x in a:
        heapq.heappush(q, -x)

    for i in range(m):
        x = heapq.heappop(q)
        x /= 2
        heapq.heappush(q,x)

    answer = 0
    for x in q:
        answer += int(-x//1)
    print(answer)
# Original solution
import math
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls.sort(reverse=True)
x=ls[0]
L=int(math.log2(x))
#2**L より大きいものをわける
def cut(lst,exp):
    for ii in range(len(lst)):
        if ii+1==len(lst):
            break
        if lst[ii+1]<exp:
           break
    return ii
m=M #残り回数
b=-1
ls3=[]
while True:
    if m==0:
        break
    a=b+1
    b=cut(ls,2**L)
    ls2=ls[a:b+1]
    ls3=ls3+ls2
    ls3.sort(reverse=True)
    for j in range(len(ls3)):
        ls3[j]=ls3[j]//2
        m-=1
        if m==0:
            break
    L-=1
#    print(ls3,m,b)
#print(ls3,ls[b+1:])
s=sum(ls3)+sum(ls[b+1:])
print(s)
    

# Optimized solution
import math
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls.sort(reverse=True)
x=ls[0]
L=int(math.log2(x))
#2**L より大きいものをわける
def cut(lst,exp):
    for ii in range(len(lst)):
        if ii+1==len(lst):
            break
        if lst[ii+1]<exp:
           break
    return ii
m=M #残り回数
b=-1
ls3=[]
while True:
    if m==0:
        break
    a=b+1
    b=cut(ls,2**L)
    ls2=ls[a:b+1]
    ls3=ls3+ls2
    if ls2!=[]:
        ls3.sort(reverse=True)
    for j in range(len(ls3)):
        ls3[j]=ls3[j]//2
        m-=1
        if m==0:
            break
    L-=1
#    print(ls3,m,b)
#print(ls3,ls[b+1:])
s=sum(ls3)+sum(ls[b+1:])
print(s)
# Original solution
import heapq
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
h = []
for e in ls:
  heapq.heappush(h, (-e,e))
for i in range(M):
  x=heapq.heappop(h)
  y=x[1]//2
  heapq.heappush(h,(-y,y))
ls2=[e[1] for e in h]
print((sum(ls2)))


# Optimized solution
import heapq
N,M=[int(s) for s in input().split()]
ls=input().split()
h = []
for e in ls:
  heapq.heappush(h, -int(e))
for i in range(M):
  x=heapq.heappop(h)
  y=(-x)//2
  heapq.heappush(h,-y)
print((-sum(h)))
# Original solution
N, M = list(map(int, input().split()))

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


mycnt = 1
while mycnt <= M:
    mylist[mylist.index(max(mylist))] = max(mylist)//2
    #print(mylist[mylist.index(max(mylist))])
    mycnt += 1

mysum = sum(mylist)


    

print(mysum)

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


heapq.heapify(A)
 
#print(A)

for _ in range(M):
  max = heapq.heappop(A) * -1
  #print(max, A)
  
  heapq.heappush(A,(max//2)*-1)
  
  #print(A)
 
print((sum(A)*-1))
# Original solution
N,M = list(map( int,input().split() ))
A = list( map(int,input().split()) )
remain = M

while remain > 0:
  i = A.index(max(A))
  A[i] = A[i]//2
  remain -= 1
print((sum(A)))


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

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

print((sum(s)))

# Optimized solution
import heapq

n,m = list(map(int,input().split()))
s = list([int(x) * -1 for x in input().split()])
#print(type(s))
heapq.heapify(s)
for _ in range(m):
    heapq.heappush(s,int(heapq.heappop(s)/2))
sum = sum(s)*-1
print(sum)
# Original solution
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

for _ in range(M):
  m = max(A)
  A[A.index(m)] = m // 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)

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

print((-sum(A)))
# Original solution
import bisect
N,M = list(map(int, input().split()))
A = sorted(map(int, input().split()))
for i in range(M):
    bisect.insort(A, A.pop()//2)
print((sum(A)))

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

while m>0:
    p=lst[-1]
    index=bisect(lst,p/2)
    for i in range(n-1,index-1,-1):
        if m>0:
            lst[i]=lst[i]/2
            m-=1
    lst=sorted(lst)
    if lst[-1]<1:
        break

ans=0
for i in lst:
    ans+=i//1
print(ans)

# Optimized solution
import sys
input=sys.stdin.readline
from decimal import Decimal
from bisect import bisect
n,m=list(map(int,input().split()))
lst=sorted(map(Decimal, input().split()))

while m>0:
    p=lst[-1]
    index=bisect(lst,p/2)
    for i in range(n-1,index-1,-1):
        if m>0:
            lst[i]=lst[i]/2
            m-=1
    lst=sorted(lst)
    if lst[-1]<1:
        break

ans=0
for i in lst:
    ans+=i//1
print(ans)
# Original solution
import os
import math

def main():
	n,m = list(map(int, input().split()))
	a_list = list(map(int, input().split()))
	a_list.sort(reverse=True)
	
	for i in range(m):
		max_num = a_list[0]
		a_list[0] = math.floor(max_num/(2))
		a_list.sort(reverse=True)
	print((sum(a_list)))
		

if __name__ == "__main__":
	main()


# Optimized solution
import os
import math
import heapq

def main():
	n,m = list(map(int, input().split()))
	a_list = list([int(x)*(-1) for x in input().split()])
	heapq.heapify(a_list)
	
	for i in range(m):
		max_num = heapq.heappop(a_list)*(-1)
		heapq.heappush(a_list, (max_num//2)*(-1))

	print(((-1)*sum(a_list)))

		

if __name__ == "__main__":
	main()
# Original solution
from heapq import heapify,heappop,heappush
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
A=list([x*(-1) for x in A])
heapify(A)
while(M>0):
    temp=heappop(A)*-1
    
    heappush(A,temp//2*-1)
    M-=1
print((sum(A)*-1))

# Optimized solution
from heapq import heapify,heappop,heappush
N,M=list(map(int,input().split()))
A=list([-int(x) for x in input().split()])
heapify(A)
for i in range(M):
    heappush(A,-(-heappop(A)//2))
print((-sum(A)))
# Original solution
import sys
input=sys.stdin.readline
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
for _ in range(m):
    i=a.index(max(a))
    a[i]=int(a[i]/2)
print((sum(a)))

# Optimized solution
import sys
import heapq
input=sys.stdin.readline
n,m=list(map(int,input().split()))
a=list([int(x)*(-1) for x in input().split()])
heapq.heapify(a)
for _ in range(m):
    mina=int(heapq.heappop(a)/2)
    heapq.heappush(a,mina)
print((sum(a)*(-1)))
# Original solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(m):
    max_idx = a.index(max(a))
    a[max_idx] = a[max_idx] // 2
print((sum(a)))

# 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):
    tar = heapq.heappop(a)
    ins = ((tar*-1) // 2)*-1
    heapq.heappush(a, ins)
a = list([x*-1 for x in a])
print((sum(a)))
# Original solution
import bisect
n, m = list(map(int, input().split()))
a = sorted([int(i) for i in input().split()])

for i in range(m):
    tmp = a.pop() // 2
    idx = bisect.bisect_left(a, tmp)
    a.insert(idx, tmp)

print((sum(a)))

# Optimized solution
import heapq

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

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

print((sum(a) * (-1)))
# Original solution
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(m):
    num = a.index(max(a))
    a[num] = max(a) // 2
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_minus = [-a for a in A]

heapify(A_minus)

for _ in range(M):
    heappush(A_minus, -((-heappop(A_minus)) // 2))
ans = -sum(A_minus)
print((int(ans)))
# Original solution
import heapq
N,M = list(map(int,input().split()))
list_A = list([int(x)*(-1) for x in input().split()])	

#print(list_A)

for i in range(M):
  heapq.heapify(list_A)
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print((-sum(list_A)))




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

#print(list_A)
heapq.heapify(list_A)
for i in range(M):
  
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

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

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

print((sum(A)))


# Optimized solution
import heapq as hq

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

#ヒープキューのために符号逆転
A=list([x * (-1) for x in A])
hq.heapify(A)

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

print((sum(A) * (-1)))
# Original solution
import bisect
N, M = list(map(int, input().split(' ')))
As = list(map(int, input().split(' ')))
# osoi
As = sorted([-a for a in As])
while M:
    hoge = -As.pop(0) // 2
    M -= 1
    while M and As and hoge < As[1]:
        hoge = hoge // 2
        M -= 1
    bisect.insort(As, -hoge)
print((-sum(As)))


# Optimized solution
import math
import heapq
n, k = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
aaa = [-a for a in aaa]
heapq.heapify(aaa)
for i in range(k):  # TLE?
    t = heapq.heappop(aaa)
    t = math.ceil(t/2)
    heapq.heappush(aaa, t)
print((-sum(aaa)))
# Original solution
# https://atcoder.jp/contests/abc141/tasks/abc141_d
from copy import deepcopy
from heapq import heappop, heappush, heapify
n, m = list(map(int, input().split()))

nums = [-int(i) for i in input().split()]
heapify(nums)
def check(nums, money, m):
    while m:
        m -= 1
        item = -1 * heappop(nums)
        item //= 2
        nums.append(-1 * item)
    pay = 0
    for num in nums:
        pay += -1 * num
        if pay > money:
            return False
    return True
l = 0
r = -1 * sum(nums)
ans = r
while l <= r:
    items = deepcopy(nums)
    mid = (l + r) // 2
    if check(items, mid, m):
        ans = min(ans, mid)
        r = mid - 1
    else:
        l = mid + 1
print(ans)

# Optimized solution
# https://atcoder.jp/contests/abc141/tasks/abc141_d
from copy import deepcopy
from heapq import heappop, heappush, heapify
n, m = list(map(int, input().split()))

items = [-int(i) for i in input().split()]
heapify(items)
while m:
    m -= 1
    item = -1 * heappop(items)
    item //= 2
    heappush(items, -1 * item)
pay = 0
for i in items:
    pay += -1 * i
print(pay)
# Original solution
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    d = A.pop(-1)/2
    bisect.insort_left(A,d)

ans=0
for i in range(N):
    ans+=math.floor(A[i])

print(ans)

# Optimized solution
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))
A = list([x * (-1) for x in A])

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

ans=0
for a in A:
    ans+=math.floor(-a)

print(ans)
# Original solution
n,m=list(map(int,input().split()))
a=[int(i) for i in input().split()]
while m>0:
    b=max(a)
    a.remove(b)
    a.append(b//2)
    m-=1
print((sum(a)))   

# Optimized solution
import heapq
n,m=list(map(int,input().split()))
a=[-int(i) for i in input().split()]
heapq.heapify(a)
for i in range(m):
    k=heapq.heappop(a)
    heapq.heappush(a,-(abs(k)//2))
print((-sum(a)))
# Original solution
#標準入力からソートまで
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
#Aの中で一番でかいのをdiscountしてまた並び替え
import bisect
for i in range(M):
    tmp = A.pop(N-1) // 2
    bisect.insort_left(A, tmp)
print((sum(A)))

# Optimized solution
#標準入力からソートまで
N, M = list(map(int, input().split()))
A = list([int(x) * (-1) for x in input().split()])
#Aの中で一番でかいのをdiscountしてまた並び替え
#優先度付きqueuemを使う
import heapq
heapq.heapify(A)
for i in range(M):
    tmp = (-1) * heapq.heappop(A) // 2
    heapq.heappush(A, tmp * (-1))
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(A)))

# Optimized solution
import heapq

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

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

print((-sum(a)))
# Original solution
import heapq

N, M = list(map(int, input().split(" ")))
A = [-int(_) for _ in input().split(" ")]

for i in range(M):
    heapq.heapify(A)
    heapq.heappush(A, -(-heapq.heappop(A)// 2))

print((-sum(A)))

# Optimized solution
import heapq

N, M = list(map(int, input().split(" ")))
A = [-int(_) for _ in input().split(" ")]

heapq.heapify(A)

for i in range(M):
    heapq.heappush(A, -(-heapq.heappop(A)// 2))
    
print((-sum(A)))