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

    var ans = 0

    fun dfs(xs: IntArray, cur: Int) {
        if (cur == n) {
            if (a.mapIndexed { i, v -> v + xs[i] }.any { it and 1 == 0 }) ans++
            return
        }
        dfs(xs.plus(-1), cur + 1)
        dfs(xs.plus(0), cur + 1)
        dfs(xs.plus(1), cur + 1)
    }

    dfs(IntArray(0), 0)

    println(ans)
}
