import copy

def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans

print(main()) import copy copy def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp bi_search money.sort() money.sort money sort left = 0 left 0 right = money[N-1]+1 right money[N-1]+1 money[N-1] money N-1 N 1 1 mid = 0 mid 0 while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp True mid = int( (left+right)/2 ) mid int( (left+right)/2 ) int (left+right)/2 left+right left right 2 cnt = 0 cnt 0 money_tmp = copy.copy(money) money_tmp copy.copy(money) copy.copy copy copy money for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
         i range(N) range N while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
         True if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
         money_tmp[i] <= mid money_tmp[i] money_tmp i mid break money_tmp[i] //= 2 money_tmp[i] money_tmp i 2 cnt += 1 cnt 1 if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

         cnt == M cnt M return mid,cnt return mid,cnt mid cnt elif cnt < M:
            right = mid
            tmp = cnt
         cnt < M cnt M right = mid right mid tmp = cnt tmp cnt elif cnt > M:
            left = mid + 1

         cnt > M cnt M left = mid + 1 left mid + 1 mid 1 if left == right:
            return right,tmp left == right left right return right,tmp return right,tmp right tmp money money M M N N def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans main N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A = list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split max_money,cnt = bi_search(A,M,N) max_money bi_search(A,M,N) bi_search A M N cnt cnt = M-cnt cnt M-cnt M cnt ans = 0 ans 0 for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
     i range(N) range N if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
     max_money >= A[i] max_money A[i] A i continue while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
     True A[i] //= 2 A[i] A i 2 if max_money >= A[i]:
                    #ans += A[i]
                    break
     max_money >= A[i] max_money A[i] A i break A.sort(reverse = True) A.sort A sort reverse = True reverse True j = 0 j 0 if A[j] == 0:
        return 0
     A[j] == 0 A[j] A j 0 return 0 0 for i in range(cnt):
        A[j] //= 2
        j += 1

     i range(cnt) range cnt A[j] //= 2 A[j] A j 2 j += 1 j 1 for i in range(N):
        ans += A[i]

     i range(N) range N ans += A[i] ans A[i] A i return ans ans print(main()) print main() main def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp bi_search def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans main
import copy

def bi_search(money,M,N):
    money.sort()
    #list = []
    #for i in range(0,money[N-1]+2,1):
        #list.append(i)
    left = 0
    right = money[N-1]+1
    mid = 0
    #print(list,left,right)
    while True:
        mid = int( (left+right)/2 )
        cnt = 0
        #print(left,right,mid)
        #print(money)
        money_tmp = copy.copy(money)
        for i in range(N):
            while True:
                #print(money_tmp[i],i)
                if money_tmp[i] <= mid:
                    break
                else:
                    money_tmp[i] //= 2
                    cnt += 1
        #print(cnt)
        if cnt == M:
            return mid,cnt
        elif cnt < M:
            right = mid
            tmp = cnt
        elif cnt > M:
            left = mid + 1

        if left == right:
            return right,tmp

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    max_money,cnt = bi_search(A,M,N)
    #print (cnt)
    cnt = M-cnt
    ans = 0
    for i in range(N):
        if max_money >= A[i]:
            continue
            #ans += A[i]
        else:
            while True:
                A[i] //= 2
                if max_money >= A[i]:
                    #ans += A[i]
                    break
    A.sort(reverse = True)
    j = 0
    if A[j] == 0:
        return 0
    for i in range(cnt):
        A[j] //= 2
        j += 1

    for i in range(N):
        ans += A[i]

    return ans

print(main())
