from functools import reduce

from itertools import product



N = int(eval(input()))

*A, = list(map(int, input().split()))

ans = 0

for t in product([-1, 0, 1], repeat=N):

    prod = reduce(lambda x, y: x*y, [a + t[i] for i, a in enumerate(A)])

    if prod % 2 == 0: ans += 1

print(ans)
N = int(eval(input()))

*A, = list(map(int, input().split()))

evens = 0

for a in A:

    if a % 2 == 0: evens += 1

ans = 3**N - 2**evens

print(ans)
from functools import reduce
from itertools import product

N = int(eval(input()))
(*A,) = list(map(int, input().split()))
ans = 0
for t in product([-1, 0, 1], repeat=N):
    prod = reduce(lambda x, y: x * y, [a + t[i] for i, a in enumerate(A)])
    if prod % 2 == 0:
        ans += 1
print(ans)

N = int(eval(input()))
(*A,) = list(map(int, input().split()))
evens = 0
for a in A:
    if a % 2 == 0:
        evens += 1
ans = 3**N - 2**evens
print(ans)

-from functools import reduce -from itertools import product - -ans = 0 -for t in product([-1, 0, 1], repeat=N): -    prod = reduce(lambda x, y: x * y, [a + t[i] for i, a in enumerate(A)]) -    if prod % 2 == 0: -        ans += 1 +evens = 0 +for a in A: +    if a % 2 == 0: +        evens += 1 +ans = 3**N - 2**evens