      MODULE intQsortMod
! 整数型のクイックソート
! precisionで整数の精度を定める．
! インデックスの小さいほうが値も小さい(昇順)．

! 参考
! https://t.doujin-constant.net/post/143374686394/fortranをより使いこなしたquick-sort

      implicit none
      integer,parameter,private :: precision = 16
      
      interface qSort
        module procedure :: intQsort
      end interface
      
      contains
      pure recursive function intQsort( a ) result( r )
        implicit none
        integer(precision), intent(in) :: a(:)
        integer(precision) :: r( size(a) )
        integer(precision) :: sample(3), len, i,j
        
        len = size( a(:) )
        if( len<=1 )then
          r = a
        else
          !select pivot
          sample(1:3) = [a(1), a(len/2), a(len)]
          do i = 1,2
            do j = 2,3
              if( sample(i)>sample(j) )then
                len = sample(i) !len is buffer
                sample(i) = sample(j)
                sample(j) = len
              end if
            end do
          end do
          
          r = [ qSort( pack(a(:), a(:)< sample(2)) ), &
                       pack(a(:), a(:)==sample(2))  , &
                qSort( pack(a(:), a(:)> sample(2)) ) ]
        end if
      end function intQsort
      END MODULE intQsortMod
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      PROGRAM logs
      use intQsortMod
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: n,k
      integer(p),allocatable :: aa(:)
      real(p),allocatable :: a(:),ratio(:)
      real(p) :: sumR
      
      read*,n,k
      allocate( aa(n),a(n),ratio(n) )
      read*,aa(1:n)
      
      a = aa
      ratio(:) = log2(a(:))
      sumR = sum( ratio )
      ratio = ceiling((k*ratio)/sumR)
      a = a/(2._p**ratio)
      
      print'(i0)',ceiling(maxval( a ))
      
      
      
      stop
      !debugg
      
      print*,ratio
      
      contains
      elemental function log2( a )
        implicit none
        real(p) :: log2
        real(p),intent(in) :: a
        log2 = log(a)/log(2._p)
      end
      
      
      END PROGRAM