program sample
    implicit none

    integer(8):: N, i, j, k, l,z
    integer(8), allocatable::A(:)
    read(*,*) N
    allocate(A(N))
    read(*,*) A
    k = 1

    do i = 1, N
        z = mod(A(i),2)
        if(z == 1) then
            l = 1
        else
            l = 2
        end if
        k = k*l
    end do

    write(*,*) 3**N - k
    deallocate(A)

    stop
end program sample