fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val listA = readLine()!!.split(" ").map { it.toInt() }
    val total = Math.pow(3.toDouble(), n.toDouble()).toInt()
    val oddCount = Math.pow(2.toDouble(), listA.count { it % 2 == 0 }.toDouble()).toInt()
    println(total - oddCount)
}

