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))
n = int(eval(input()))

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



print((3 ** n - 2 ** len([a for a in A if a % 2 == 0])))
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))

n = int(eval(input()))
A = list(map(int, input().split()))
print((3**n - 2 ** len([a for a in A if a % 2 == 0])))

-count = 1 -for a in A: -    count *= 2 if a % 2 == 0 else 1 -print((3**n - count)) +print((3**n - 2 ** len([a for a in A if a % 2 == 0])))