class PQ{
    var size:Int = 0
    var heap = [Double]()
    
    func add(x:Double){
        heap.append(x)
        size += 1
        var index:Int = size - 1
        while(true){
            if(index == 0){
                break
            }
            let par_index:Int = (index-1) / 2
            if(heap[par_index] <= heap[index]){
                break
            }
            let tmp:Double = heap[index]
            heap[index] = heap[par_index]
            heap[par_index] = tmp
            index = par_index
        }
    }
    
    func getMin() -> Double{
        let res:Double = heap[0]
        var index = 0
        heap[index] = heap[size-1]
        size -= 1
        heap.removeLast()
        while(true){
            let leftIndex:Int = index * 2 + 1
            let rightIndex:Int = index * 2 + 2
            
            if(leftIndex >= size) {
                break
            }
            let L = heap[leftIndex]
            var R:Double = 2000000000
            if(rightIndex < size){
                R = heap[rightIndex]
            }
            
            if(heap[index] <= L && heap[index] <= R){
                break
            }else{
                if(L <= R){
                    let tmp:Double = heap[index]
                    heap[index] = heap[leftIndex]
                    heap[leftIndex] = tmp
                    index = leftIndex
                }else{
                    let tmp = heap[index]
                    heap[index] = heap[rightIndex]
                    heap[rightIndex] = tmp
                    index = rightIndex
                }
            }
        }
        return res
    }
    
}


var X = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var N:Int = X[0]
var M:Int = X[1]
for _ in 0..<N {
    let n: Int = Int(readLine()!)!
}
/*

var pq = PQ()

for _ in 0..<N {
    let n: Int = Int(readLine()!)!
    let x:Double = -Double(n)
    pq.add(x)
}


for _ in 0..<M {
    var min:Double = pq.getMin()
    min /= 2.0
    pq.add(min)
}

var ans:Int = 0

for _ in 0..<N {
    ans += Int(-pq.getMin())
}

print(ans)
*/

