fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    println(solve(n, a, 1))
}

fun solve(rem: Int, a: List<Int>, isOdd: Int): Int {
    if (rem == 0) {
        return if (isOdd == 0) return 1 else 0
    }
    val idx = rem - 1
    return (-1..1).sumBy {
        val nextIsOdd = (isOdd * (a[idx] + it)) % 2
        solve(rem - 1, a, nextIsOdd)
    }
}
