You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 ≤ N ≤ 10, 1 ≤ Ai ≤ 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.

# Buggy version:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    A = list(map(int, input().split()))
    allB = exc = 1
    for i in n:
        allB *= 3
        if i%2 == 0:
            exc *= 2
    ans = allB - exc
    print(ans)

if __name__ == '__main__':
    main()

# Fixed version:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    A = list(map(int, input().split()))
    allB = 3**n
    exc = 1
    for i in range(n):
        if A[i]%2 == 0:
            exc *= 2
    ans = allB - exc
    print(ans)

if __name__ == '__main__':
    main()

# Buggy version:
def solve(n,a):
  even = 0
  
  for i in range(n):
    if a[i] % 2 == 1:
      even += 1
  
  return 3**n - 2**even
  
def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(solve(N,a))

# Fixed version:
def solve(n,a):
  even = 0
  
  for i in range(n):
    if a[i] % 2 == 0:
      even += 1
  
  return 3**n - 2**even
  
def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(solve(N,a))
  
main()

# Buggy version:
import itertools

n = int(input())
a = tuple(map(int,input().split()))
ans = 0
for l in itertools.product([-1,0,1],n):
  t = 1
  for i in range(n):
    t*=(a[i]+l[i])
  if t%2==0:
    ans+=1
print(ans)

# Fixed version:
import itertools

n = int(input())
a = tuple(map(int,input().split()))
ans = 0
for l in itertools.product([-1,0,1],repeat=n):
  t = 1
  for i in range(n):
    t*=(a[i]+l[i])
  if t%2==0:
    ans+=1
print(ans)

# Buggy version:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    ans = 3 ** n
    a = sum(map(lambda x: x & 1, a))
    na = n - a
    print(ans - 2 ** na * a)
    return


#main
if __name__ == '__main__':
    solve()


# Fixed version:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    ans = 3 ** n
    a = sum(map(lambda x: x & 1, a))
    na = n - a
    print(ans - 2 ** na)
    return


#main
if __name__ == '__main__':
    solve()

# Buggy version:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

c_even = len(1 for a in A if a % 2 == 0)
ans = 3**len(A) - 2**c_even
print(ans)


# Fixed version:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

c_even = len([1 for a in A if a % 2 == 0])
ans = 3**len(A) - 2**c_even
print(ans)

# Buggy version:
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)

# Fixed version:
n = int(input())
cnt = 1
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)

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

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

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i range(n):
  if a[i]%2==0:
    cnt+=1
ans=(3*n)-2*cnt
print(ans)

# Fixed version:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i]%2==0:
        cnt+=1
print(3**n-2**cnt)

# Buggy version:
n = int(input())
A = list(map(int,input().split()))

even = odd = 0

for a in A:
  if a%2:
    odd += 1
  else:
    even += 1
    
print(3**n - (odd+(even*2)**n))

# Fixed version:
N = int(input())
A = list(map(int, input().split()))

even, odd = 0, 0
for a in A:
	if a % 2:
		odd += 1
	else:
		even += 1

if not even:
	print(3 ** N - 1)
else:
	print(3 ** N - 2 ** even)

# Buggy version:
n=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in a:
  if i%2==0:
   	x+=1
print(3**n-2**x)

# Fixed version:
n=int(input())
a=list(map(int,input().split()))
x=0
for i in a:
    if i%2==0:x+=1
print(3**n-2**x)

# Buggy version:
n=int(input())
arr=list(map(int,input().split()))
tmp=1
for i in range(i):
  if arr[i]%2==0:
    tmp*=2
print(3**n-tmp)

# Fixed version:
n=int(input())
arr=list(map(int,input().split()))
tmp=1
for i in range(n):
  if arr[i]%2==0:
    tmp*=2
print(3**n-tmp)

# Buggy version:
n=int(input())
ans=2**n
m=1
for a in map(int,input().split()):
  if a%2==0:
    m*=2
print(ans-m)

# Fixed version:
n=int(input())
ans=3**n
m=1
for a in map(int,input().split()):
  if a%2==0:
    m*=2
print(ans-m)

# Buggy version:
N = int(input())
A = [int(i) for i in input().split()]

ans = 2**N
tmp = 1
for a in A:
  if a%2==0:
    tmp *= 2
print(ans - tmp)

# Fixed version:
N = int(input())
A = [int(i) for i in input().split()]

ans = 3**N
tmp = 1
for a in A:
  if a%2==0:
    tmp *= 2
print(ans - tmp)

# Buggy version:
from functools import reduce
n=int(input())
print(3**n-reduce(lambda x, y: x * y, 2-int(s)%2 for s in input().split()))

# Fixed version:
from functools import reduce
n=int(input())
print(3**n-reduce(lambda x, y: x * y, (2-int(s)%2 for s in input().split())))

# Buggy version:
print(3**int(input())-2**sum(int(s)%2 for s in input().split()))

# Fixed version:
print(3**int(input())-2**sum(~int(s)%2 for s in input().split()))

# Buggy version:
n = int(input())
a = list(map(int,input().split()))
print(a)
o = 1


for i in range(len(a)):
    if a[i]%2 == 1:
        #odd
        o *= 1
    else:
        #even
        o *= 2

print(3**len(a)-o)


# Fixed version:
n = int(input())
a = list(map(int,input().split()))
o = 1


for i in range(len(a)):
    if a[i]%2 == 1:
        #odd
        o *= 1
    else:
        #even
        o *= 2

print(3**len(a)-o)

# Buggy version:
n=int(input())
s=input().split()
x=1
for i in s:
 if(int(i)%2==0):
  x*=2
print(2**n-x)

# Fixed version:
n=int(input())
s=input().split()
x=1
for i in s:
 if(int(i)%2==0):
  x*=2
print(3**n-x)

# Buggy version:
import itertools


def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    matrix = [[] for _ in range(N)]
    for i in range(N):
        matrix[i].append(A[i] - 1)
        matrix[i].append(A[i])
        matrix[i].append(A[i] + 1)

    cnt = 0
    for element in list(itertools.product(*matrix)):
        for i in range(N):
            if element[i] % 2 == 0:
                cnt += 1
                break

    print(cnt)


 solve()

# Fixed version:
import itertools


def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    matrix = [[] for _ in range(N)]
    for i in range(N):
        matrix[i].append(A[i] - 1)
        matrix[i].append(A[i])
        matrix[i].append(A[i] + 1)

    cnt = 0
    for element in list(itertools.product(*matrix)):
        for i in range(N):
            if element[i] % 2 == 0:
                cnt += 1
                break

    print(cnt)


solve()

# Buggy version:
n = int(input())
a = [int(i) for i in input().split()]
print(a)

cnt = 0
for i in range(n):
    if a[i] % 2 == 0:
        cnt += 1

x = 3 ** n - 2 ** cnt

print(x)

# Fixed version:
n = int(input())
a = [int(i) for i in input().split()]

cnt = 0
for i in range(n):
    if a[i] % 2 == 0:
        cnt += 1

x = 3 ** n - 2 ** cnt

print(x)

# Buggy version:
N = int(input())
a = map(int, input().split())
tmp = 3 ** N
g = len([c for c in a if a % 2 == 0])
print(tmp - (2 ** g))

# Fixed version:
N = int(input())
a = map(int, input().split())
tmp = 3 ** N
g = len([c for c in a if c % 2 == 0])
print(tmp - (2 ** g))

# Buggy version:
def get_result(A):
    res = 1
    total = 1
    for i, ai in enumerate(A):
        print(ai, res, total)
        res *= 2 if ai % 2 == 0 else 1
        total *= 3 if ai > 1 else 2
    return total - res

A = [int(ai) for ai in input().split()]
print(get_result(A))

# Fixed version:
def get_result(A):
    res = 1
    total = 3 ** len(A)
    for i, ai in enumerate(A):
        res *= 2 if ai % 2 == 0 else 1
    return total - res
n = input()
A = [int(ai) for ai in input().split()]
print(get_result(A))

# Buggy version:
n=int(input())
n=3**n
a=list(map(int,input().split()))

a=[2 if i%2==0 for i in a else 1]

cnt=1

for i in a:
  cnt*=i
  
  
print(n-cnt)


# Fixed version:
n = int(input())
a = list(map(int, input().split()))

odds = 1
for i in range(n) :
    if a[i]%2 == 0 :
        odds *= 2
else :
    print(3**n-odds)

# Buggy version:
N = int(input())
A = list(map(int, input().split()))
ans = 3 ** N
for i in A:
	if i % 2 == 0:
		ans -= 2
print(ans)


# Fixed version:
N = int(input())
A = list(map(int, input().split()))
odd_cand = 1
ans = 1
for i in A:
    if i%2==0:
        odd_cand *= 2
    ans *= 3

print(ans - odd_cand)

# Buggy version:
n = int(input())
a = list(map(int,input().split()))
k = 1
for k in a:
  if k%2 == 0:
    k *= 2
print(3**n-k)

# Fixed version:
n = int(input())
a = list(map(int, input().split()))
k = 1
for i in a:
	if i%2 == 0:
		k *= 2
print(3**n-k)

# Buggy version:
#! usr/bin/env python3
#B:

N = int(input())

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

count = 1

for i in A:
	if A % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)

# Fixed version:
#! usr/bin/env python3
#B:

N = int(input())

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

count = 1

for i in A:
	if i % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)

# Buggy version:
N=int(input())
A=list(map(int,input().split()))
odd=0
for i in range(N):
  if A[i]%2==1: odd+=1

print(3**N-2**odd)

# Fixed version:
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if A[i] % 2 == 0:
        cnt+= 1
        
x = 3**N - 2 **cnt
print(x)

# Buggy version:
n = int(input())
*A, = map(int, input().split())

from itertools import product

ans = 0
for P in product(range(3), repeat=10):
    even = 0
    for i in range(n):
        b = A[i] + P[i] - 1
        even |= (b % 2) == 0
    if even:
        ans += 1
print(ans)



# Fixed version:
n = int(input())
*A, = map(int, input().split())

from itertools import product

ans = 0
for P in product(range(3), repeat=n):
    even = 0
    for i in range(n):
        b = A[i] + P[i] - 1
        even |= (b % 2) == 0
    if even:
        ans += 1
print(ans)