program main
    implicit none
    integer::n,ans,i,t
    integer,allocatable::x(:)
    read(*,*) n
    allocate(x(n))
    read(*,*) x
    
    t=1
    
    do i=1,n
        if(mod(x(i),2)==0)then
        	t=t*2
        end if
    end do
    
    ans=3**n-t
    
    write(*,*) ans
    deallocate(x)
    
    stop
end program main
    
    