n,m = gets.chomp.split(" ").map(&:to_i)
price = gets.chomp.split(" ").map(&:to_i)
ticket = Array.new(n,0) 
m.times do 
 discount =  price.zip(ticket).map{|ary| ary[0]/2**(ary[1]) - ary[0]/2**(ary[1]+1)}
 ticket[discount.index(discount.max)]+=1
end
puts price.zip(ticket).map{|ary| ary[0]/(2**ary[1])}.inject(&:+)

