program sample
	implicit none
    integer :: N,i,count1,count2,a
    integer, allocatable :: x(:)
    
    read(*,*) N
    
    allocate(x(N))
    

  	read(*,*) x
    
    count1 = 3**N
    count2 = 1
    
    
    do i=1,N
    	if (mod(x(i),2) == 0) then
        	count2 = count2 * 2
        else
        	count2 = count2 * 1
     	end if
   	end do
    
    write(*,*) count1 - count2
    
    deallocate(x)
    
    stop
end program sample