from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

lb = -1
ub = 1e+09 + 3
total_money = sum(a)

while ub - lb > 1:
    mid = (lb + ub) // 2
    count = 0
    ac = a[:]
    for i in range(len(ac)):
        while ac[i] > mid:
            if ac[i] == 0:
                break
            ac[i] //= 2
            count += 1
        if count > m:
            break
    if count > m:
        lb = mid
    else:
        ub = mid
        ac.sort(reverse=True)
        if count < m:
            for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
        total_money = sum(ac)


print(total_money) from sys import stdin int(x) for x in stdin.readline().rstrip().split() for x in stdin.readline().rstrip().split() x stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for x in stdin.readline().rstrip().split() int(x) int x n, m = [int(x) for x in stdin.readline().rstrip().split()] n [int(x) for x in stdin.readline().rstrip().split()] m int(x) for x in stdin.readline().rstrip().split() for x in stdin.readline().rstrip().split() x stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for x in stdin.readline().rstrip().split() int(x) int x a = [int(x) for x in stdin.readline().rstrip().split()] a [int(x) for x in stdin.readline().rstrip().split()] lb = -1 lb -1 ub = 1e+09 + 3 ub 1e+09 + 3 1e+09 3 total_money = sum(a) total_money sum(a) sum a while ub - lb > 1:
    mid = (lb + ub) // 2
    count = 0
    ac = a[:]
    for i in range(len(ac)):
        while ac[i] > mid:
            if ac[i] == 0:
                break
            ac[i] //= 2
            count += 1
        if count > m:
            break
    if count > m:
        lb = mid
    else:
        ub = mid
        ac.sort(reverse=True)
        if count < m:
            for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
        total_money = sum(ac) ub - lb > 1 ub - lb ub lb 1 mid = (lb + ub) // 2 mid (lb + ub) // 2 lb + ub lb ub 2 count = 0 count 0 ac = a[:] ac a[:] a : for i in range(len(ac)):
        while ac[i] > mid:
            if ac[i] == 0:
                break
            ac[i] //= 2
            count += 1
        if count > m:
            break
     i range(len(ac)) range len(ac) len ac while ac[i] > mid:
            if ac[i] == 0:
                break
            ac[i] //= 2
            count += 1
         ac[i] > mid ac[i] ac i mid if ac[i] == 0:
                break
             ac[i] == 0 ac[i] ac i 0 break ac[i] //= 2 ac[i] ac i 2 count += 1 count 1 if count > m:
            break
     count > m count m break if count > m:
        lb = mid
    else:
        ub = mid
        ac.sort(reverse=True)
        if count < m:
            for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
        total_money = sum(ac) count > m count m lb = mid lb mid ub = mid ub mid ac.sort(reverse=True) ac.sort ac sort reverse=True reverse True if count < m:
            for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
         count < m count m for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
         i range(m-count) range m-count m count if i >= n:
                    break
                 i >= n i n break ac[i] //= 2 ac[i] ac i 2 total_money = sum(ac) total_money sum(ac) sum ac print(total_money) print total_money mid = (lb + ub) // 2 (lb + ub) // 2 mid count = 0 0 count ac = a[:] a[:] ac count += 1 1 count m = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] m total_money = sum(ac) sum(ac) total_money lb = mid mid lb a = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] a ub = 1e+09 + 3 1e+09 + 3 ub ub = mid mid ub lb = -1 -1 lb n, m = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] n total_money = sum(a) sum(a) total_money
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

lb = -1
ub = 1e+09 + 3
total_money = sum(a)

while ub - lb > 1:
    mid = (lb + ub) // 2
    count = 0
    ac = a[:]
    for i in range(len(ac)):
        while ac[i] > mid:
            if ac[i] == 0:
                break
            ac[i] //= 2
            count += 1
        if count > m:
            break
    if count > m:
        lb = mid
    else:
        ub = mid
        ac.sort(reverse=True)
        if count < m:
            for i in range(m-count):
                if i >= n:
                    break
                ac[i] //= 2
        total_money = sum(ac)


print(total_money)