program main
  implicit none
  integer :: N, M
  integer, allocatable :: A(:)
  integer, allocatable :: A2(:)
  integer(8), allocatable :: A3(:)
  integer :: tmp
  integer :: j2
  integer :: i,j
  read(*,*) N,M
  allocate(A(N))
  allocate(A3(N))
  read(*,*) A(:)
  A2 = iqsort(A) ! sorted
  j2 = N
  do i = 1,M
     A2(N) = A2(N) / 2
     !write(*,*) "i:",i
     do j = 1,j2
        if (   A2(N) <= A(j)) then
           ! insert A(N) to A(j)
           A(:) = A2(:) ! save
           !A2(1:j-2) = A(1:j-2)
           A2(j) = A(N)
           A2(j+1:N) = A(j:N-1)
           j2 = j
           exit
        end if
     end do
     !write(*,*) "A2:",A2
  end do
  A3 = A2
  write(*,'(i0)') sum(A3)
  stop
contains
  recursive function iqsort(ix) result(ires)
    integer, allocatable :: ires(:)
    integer, intent(in)  :: ix(:)
    integer :: k
    if (size(ix) <= 1) then 
       ires = ix
    else  
       k = ix(size(ix) / 2)
       ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
    end if
  end function iqsort  
end program
   
