program codefestival2017qualc
  implicit none
  integer :: n
  integer,dimension(:),allocatable :: a
  read *, n
  allocate(a(n))
  read *, a
  print *, 3**n-product(merge(2,1,mod(a,2)==0))
end program codefestival2017qualc
