_,m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
f_max = a.max
total = a.inject(&:+)
node = Array.new(f_max+1){0}
a.each do |c|
  node[c] += 1
end
(1..f_max).reverse_each do |i|
  while node[i] > 0
    node[i] -= 1
    node[i/2] += 1
    total -= (i/2)+(i%2)
    m -= 1
    if m < 1
      break
    end
  end
  if m < 1
    break
  end
end
p total