We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).  In particular, any integer sequence is similar to itself.  You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N.  How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?
import sys
from io import StringIO
import unittest
import logging
logging.basicConfig(level=logging.DEBUG)

def resolve():
    n = int(input())
    dat = list(map(int, input().split()))
    total = 3 ** n
    countzero = 0
    countodd = []

    for i in range(n):
        if dat[i] % 2 == 0:
            countodd.append(2)
        else:
            countodd.append(1)
    xxx = 1
    for i in range(n):
        xxx *= countodd[i]

    total -= xxx
    print(total)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_input_1(self):
        print("test_input_1")
        input = """2
2 3"""
        output = """7"""
        self.assertIO(input, output)
    def test_input_2(self):
        print("test_input_2")
        input = """3
3 3 3"""
        output = """26"""
        self.assertIO(input, output)
    def test_input_3(self):
        print("test_input_3")
        input = """1
100"""
        output = """1"""
        self.assertIO(input, output)
    def test_input_4(self):
        print("test_input_4")
        input = """10
90 52 56 71 44 8 13 30 57 84"""
        output = """58921"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()
n = int(input())
dat = list(map(int, input().split()))
total = 3 ** n
countzero = 0
countodd = []

for i in range(n):
    if dat[i] % 2 == 0:
        countodd.append(2)
    else:
        countodd.append(1)
xxx = 1
for i in range(n):
    xxx *= countodd[i]

total -= xxx
print(total)