program main
implicit none
integer :: n
integer , allocatable :: a(:), nc(:)
integer , parameter :: a_lim =1000000000
integer :: i, nc_2

read(*,*) n
allocate(a(n))
allocate(nc(n))
read(*,*) a

nc = 0
do i = 1, n
   do while ( mod(a(i),2) ==1 )
      nc(i) = nc(i) + 1
      a(i)  = a(i)/2
   end do
end do

nc_2 = max(nc(1:n))

do i = 1, n
if(nc(i) /= nc_2) then
   a(i) = a(i)/(2**nc(i))
   do while (a(i).le.1000000000)
      a(i) = a(i)*3
      nc(i) = nc(i)+1
   end do
end if
end do

write(*,'(i0)') min(nc(1:n))

end program main