from itertools import product



n = int(eval(input()))

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



count = 0

for C in product((-1, 0, 1), repeat=n):

  total = 1

  for a, c in zip(A, C):

    total *= (a + c)

  if total % 2 == 0:

    count += 1

print(count)
n = int(eval(input()))

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



count = 1

for a in A:

  count *= 2 if a % 2 == 0 else 1

print((3 ** n - count))
from itertools import product

n = int(eval(input()))
A = list(map(int, input().split()))
count = 0
for C in product((-1, 0, 1), repeat=n):
    total = 1
    for a, c in zip(A, C):
        total *= a + c
    if total % 2 == 0:
        count += 1
print(count)

n = int(eval(input()))
A = list(map(int, input().split()))
count = 1
for a in A:
    count *= 2 if a % 2 == 0 else 1
print((3**n - count))

-from itertools import product - -count = 0 -for C in product((-1, 0, 1), repeat=n): -    total = 1 -    for a, c in zip(A, C): -        total *= a + c -    if total % 2 == 0: -        count += 1 -print(count) +count = 1 +for a in A: +    count *= 2 if a % 2 == 0 else 1 +print((3**n - count))