import Control.Applicative
import Control.Monad
import Data.List

main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    let evs = length $ filter even as
    let ods = length $ filter odd as
    let a1 = 2 ^ evs
    let a2 = 1 ^ ods
    print $ 3 ^ n - (a1 * a2)