program sample
  implicit none
  integer N, a, k, t, i
  integer, allocatable :: x(:)
  read(*,*) N
  allocate(x(N))
  k = 1
  t = 1
  read(*,*) x
  do i = 1, N
   
   if ( mod(x(i), 2) == 0) then
    k = k * 2
   endif
   if (x(i) /= 1) then
    t = t * 3
   else
    t = t * 2
   endif
  end do
  write(*,*) t - k
  
  stop
end program sample 