program prob4
    implicit none
    integer :: N, cnt, i, ans
    integer, allocatable :: a(:)

    read(*,*) N
    allocate(a(N))
    read(*,*) a
    
    cnt = 0
    do i = 1, N
        if(mod(a(i), 2) == 0) then
            cnt = cnt + 1
        end if
    end do

    ans = 3**N - 2**cnt

    write(*,*) ans

    stop
contains
end program prob4   