fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt)
    var all = 3
    repeat(n - 1) {
        all *= 3
    }

    val reuslt = all - an.map { if (it % 2 == 1) 1 else 2 }.reduce { i1, i2 -> i1 * i2 }
    println(reuslt)
}