Problem:
 Score : 200 points    Problem Statement 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?      Constraints  1 \leq N \leq 10  1 \leq A_i \leq 100         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print the number of integer sequences that satisfy the condition.        Sample Input 1 2
2 3      Sample Output 1 7  There are seven integer sequences that satisfy the condition:   1, 2  1, 4  2, 2  2, 3  2, 4  3, 2  3, 4        Sample Input 2 3
3 3 3      Sample Output 2 26       Sample Input 3 1
100      Sample Output 3 1       Sample Input 4 10
90 52 56 71 44 8 13 30 57 84      Sample Output 4 58921

Solution (Python):
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)

Solution (Python):
from operator import mul
from functools import reduce

n = int(input())
a = list(map(lambda x: 1 if int(x) % 2 else 2, input().split()))
print(3 ** n - reduce(mul, a))

Solution (Python):
N = int(input())
a = map(int, input().split())

s = pow(3, N)
odd = 1
for ai in a:
  if ai % 2 == 0:
    odd *= 2
print(s - odd)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

i = 0
for _a in a:
    if _a % 2 == 0:
        i += 1
print(3**N - 2**i)

Solution (Python):
N = int(input())
H = [2 - (int(i)%2) for i in input().split()]
k = 1
for i in H:
    k *= i
print(3**N - k)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
m = readl()

a = 1
b = 1

for i in m:
    a *= 3
    if i % 2 == 0:
        b *= 2
ans = a - b
print(ans)

Solution (Python):
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)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
def dfs(i, x):
    global cnt
    if i == N:
        if x == 0:
            cnt += 1
        return
        
    dfs(i+1, ((A[i]+1) % 2) * x)
    dfs(i+1, (A[i] % 2) * x)
    dfs(i+1, ((A[i]-1) % 2) * x)

    return cnt

cnt = dfs(0, 1)

print(cnt)

Solution (Python):
N = int(input())
As = list(map(int,input().split()))

tmp = 1
for i in range(N):
    if As[i] % 2 == 0:
       tmp *= 2

print(3 ** N - tmp)

Solution (Python):
N = int(input())
As = list(map(int,input().split()))


def dfs(A_s, index,Bss):
    if index == N:
        tmp = 1
        for b in Bss:
            tmp *= b
        return 1 if tmp % 2 == 0 else 0
    b_mi = Bss.copy()
    b_mi.append(A_s[index] - 1)

    b = Bss.copy()
    b.append(A_s[index])

    b_pl = Bss.copy()
    b_pl.append(A_s[index] + 1)
    return dfs(A_s,index + 1, b_mi) + dfs(A_s,index + 1,b) + dfs(A_s,index + 1,b_pl)


print(dfs(As,0,[]))

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))

ans = 3 ** N
even = 1
for i in range(N):
    if L[i] % 2 == 0:
        even *= 2
print(ans - even)

Solution (Python):
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)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

dp=[[0,0]for i in range(N+1)]


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

Solution (Python):

"""
B - Similar Arrays
https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_b

"""
import sys


def solve(N, array):
    ans = 3**N
    evens = [a for a in array if a%2==0]
    ans -= 2**len(evens)
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
cnt = [0]*2
for i in A:
    cnt[i%2]+=1
print(3**N-2**cnt[0])

Solution (Python):
N = int(input())
nums = list(map(int,input().split(" ")))
minus = 1
for num in nums:
    if num %2 == 0:
        minus *= 2

print(3 ** N -minus)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(N):
    if A[i]%2==0:
        ans*=2
print(3**N-ans)

Solution (Python):
n=int(input())
A=[int(i) for i in input().split()]
count=0
for a in A:
  if a%2==0:
    count+=1
print(3**n-2**count)

Solution (Python):
N = int(input())
lst_A = list(map(int, input().split()))
all_pattern = 3 ** N
odd_pattern = 1


for a in lst_A:
    if a%2 == 0:
        odd_pattern *= 2
ans = all_pattern - odd_pattern


print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split(" ")))

all_number = 1
all_odd = 1
for a in A:
  all_number *= 3
  all_odd *= 2 - a%2
  
print(all_number-all_odd)

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

Solution (Python):
N=int(input())

A=list(map(int,input().split()))
odd=0
even=0
for i in A:
  if i%2==1:
    odd+=1
  else:
    even+=1

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

Solution (Python):
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)

Solution (Python):
N = int(input())
As = [int(x) for x in input().split()]

diff = 1
for A in As:
    if A % 2 == 0:
        diff *= 2
    else:
        diff *= 1
ans = int(pow(3, N)) - diff

print(ans)

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

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
even = 0
odd = 0
for i in range(N):
  if a[i] % 2 == 0:
    even += 1
  else:
    odd += 1
print(3 ** N - 2 ** even)

Solution (Python):
n = int(input())
alist = list(map(int, input().split()))
oddn = 1
for a in alist:
  if a % 2 == 0:
    oddn *= 2
print(pow(3, n) - oddn)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

cnt=1
for i in range(N):
    if A[i]%2==0:
        
        cnt*=2
    else:
        
        cnt*=1


print(3**N-cnt)

Solution (Python):
n,a=int(input()),list(map(int,input().split()));ans=1
for i in a:
  if i%2==0:ans*=2
print(3**n-ans)

Solution (Python):
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)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
count = 0
mult = 1
for i in range(N):
    if i==0:
        if A[i]%2==0:
            count+=3**(N-1)
            mult *= 2
        else:
            count+=2*3**(N-1)
        continue
    if A[i]%2==0:
        count += mult*3**(N-i-1)
        mult *= 2
    else:
        count += mult*2*3**(N-i-1)


print(count)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]
even = 0

for i in A:
    if i % 2 == 0:
        even += 1

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

Solution (Python):
N=int(input())
A=list(map(int,input().split(' ')))
odds=1
for a in A:
  odds*=(2-a%2)
print(3**N-odds)

Solution (Python):
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())))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ocnt = 1
for i in a:
  if not i%2:
    ocnt *= 2
print(3**n - ocnt)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
j = 1
for i in range(N):
    if A[i] % 2 != 0:
        j *= 1
    else:
        j *= 2
ans = 3**N - j
print(ans)

Solution (Python):
print(3**int(input())-2**sum(~int(s)%2for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(int(s)%2==0for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(int(s)%2==0for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(~int(s)%2for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(~int(s)%2 for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(~int(s)%2 for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(int(s)%2==0 for s in input().split()))

Solution (Python):
print(3**int(input())-2**sum(int(s)%2==0 for s in input().split()))

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
cnt = 1
for i in range(N):
  if L[i]%2 == 0:
    cnt *= 2
print(3**N-cnt)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
a=pow(3,n)
b=1
for i in l:
  if i%2==0:
    b*=2
print(a-b)

Solution (Python):
n = int(input())
a = [int(m) for m in input().split()]
cnt = 0
for i in range(n):
    if a[i] % 2 == 0:
        cnt += 1
print(3 ** n - 2 ** cnt)

Solution (Python):
n = int(input())
a = list(int(i) for i in input().split())
ans = 1
ans2 = 1
for i in a:
  if i%2 == 0:
   ans = ans *3
   ans2 = ans2 *2
  else:
   ans = ans*3
   ans2 = ans2*1
print(ans-ans2)

Solution (Python):
n=int(input())
a=[i%2 for i in list(map(int,input().split()))]
print(3**n-2**(n-sum(a)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
print(3**N-2**len(list(filter(lambda x: x%2==0, A))))

Solution (Python):


import sys

def solve(n, ls_a):
    numEven = len([a for a in ls_a if a % 2 == 0])
    print(3 ** n - 2 ** numEven)

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_a = list(map(int, ws))
    return (n, ls_a,)

def main():
    solve(*readQuestion())


main()

Solution (Python):
import itertools
N = int(input())
A = list(map(int,input().split()))

ans = 0
for ptn in itertools.product(range(-1,2),repeat=N):
    m = 1
    for a,d in zip(A,ptn):
        m *= (a+d)
        if m%2==0:
            ans += 1
            break
print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=0
for i in range(N):
    if a[i]%2==0:
        b+=1
print(3**N-2**b)

Solution (Python):
N = int(input())
A = [int(_) for _ in input().split()]
odd = 1
for a in A:
    if a % 2 == 0:
        odd *= 2
print(3**N - odd)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=1
for t in a:
    if t%2==0:
        x*=2
print(3**n-x)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

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

Solution (Python):
import numpy as np
N = int(input())
L = list(map(int,input().split()))
ans = 0
P = []
for i in range(N) :
    if L[i] % 2 == 0 :
        p = 2
    else :
        p = 1
    P.append(p)

ans = 3**N - np.prod(P)
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

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

Solution (Python):
N = int(input())
s = 1
A = list(map(int, input().split()))
for i in range(N):
	if A[i] % 2 == 1:
		s = s * 1
	else:
		s = s * 2

print(3 ** N - s)

Solution (Python):
print(3**int(input())-2**sum([~i%2for i in map(int,input().split())]))

Solution (Python):
def get_digit(n, digit):
    for i in range(digit):
        n //= 3
    return n % 3


n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(3**n):
    for j in range(len(A)):
        if (A[j]+get_digit(i, j)-1) % 2 == 0:
            ans += 1
            break
print(ans)

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

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
ans=3**n
m=1
for i in a:
    m*=2-i%2
print(ans-m)

Solution (Python):
n = int(input())
list_a = list((map(int, input().split())))
even_count = 0
for number in list_a:
    if number % 2 == 0:
        even_count += 1
print(int( (3**n) - (2**even_count) ))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
L = []
for a in A:
    L.append([a-1, a, a+1])
from itertools import product
ans = 0
for t in product(*L):
    k = 1
    for n in t:
        k *= n
    if k%2==0:
        ans += 1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
hiku = 1
for i in a:
    if i % 2 == 0:
        hiku *= 2
print(3 ** n - hiku)

Solution (Python):
s=3**int(input())
t=1
for i in list(map(int,input().split())):
    t*=1+int(i%2==0)
print(s-t)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
m = 1
for nums in A:
  if nums%2 == 0:
    m = m*2
print(3**N-m)

Solution (Python):
from itertools import product
from functools import reduce

n=int(input())
*l,=map(int,input().split())
v=0

for i in product(*map(lambda x:range(x-1,x+2),l)):
  if reduce(lambda x,y:x*y,i)%2==0:
    v+=1
print(v)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

even = 0
for ai in a:
    if ai % 2 == 0:
        even += 1
print(3**n-2**even)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
o = 1


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

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

Solution (Python):
N = int(input())
ans = 3**N
t = 1
for i in input().split():
    x = int(i)
    if x % 2 == 0:
        t *= 2
ans -= t
print(ans)

Solution (Python):
N = int(input())
c = 1
for i in map(int, input().split()):
    if i % 2 == 0:
        c *= 2
print(3 ** N - c)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
    if i % 2 == 0:
        ans *= 2
print(pow(3, N) - ans)

Solution (Python):



def main():
    n = int(input())
    a = list(map(int, input().split()))
    odd_patterns = 1

    for ai in a:
        if ai % 2 == 0:
            odd_patterns *= 2

    print(3 ** n - odd_patterns)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
wana = 1
for a in aa:
	if a%2 == 0:
		wana *= 2
	else:
		wana *= 1

print(3**N-wana)

Solution (Python):
print(3**int(input())-2**sum(map(lambda x:(int(x)+1)%2,input().split())))

Solution (Python):
print(3**int(input())-2**sum(map(lambda x:(int(x)+1)%2,input().split())))

Solution (Python):
'''
aiが偶数のとき
似ている配列は
ai +- 1:奇数
ai:偶数

aiが奇数のとき
似ている配列は
ai +- 1:偶数
ai:奇数

似ている配列すべてのパターン数(3 ** N)から
奇数のみのパターン数を引けばいい
aiが偶数なら奇数2パターン
aiが奇数なら奇数1パターン
をfor i in range(N)で掛け合わせる
'''

n = int(input())
a = list(map(int, input().split()))
ttl = 3 ** n
odd_ttl = 1
for i in range(n):
    odd_ttl *= 2 if (a[i] % 2 == 0) else 1
print(ttl - odd_ttl)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
e = 0
for k in A:
    if k%2 == 0:
        e += 1
print(3**N-2**e)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]

num_even = 0
for k in A:
  if k % 2 == 0:
    num_even += 1

print(pow(3, N) - pow(2, num_even))

Solution (Python):
import numpy
import itertools

N = int(input())
A = [int(i) for i in input().split()]

per = itertools.product([-1,0,1], repeat=N)
ans = 0
for p in per:
  combined = numpy.array([x - y for (x,y) in zip(A,p)])
  product = numpy.prod(combined)
  if product % 2 == 0:
    ans += 1
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[True if i%2==0 else False for i in a].count(True)
print(3**n-2**b)

Solution (Python):
N = int(input())
src = list(map(int,input().split()))
ans = 3**N
even = len([a for a in src if a%2==0])
ans -= 2**even
print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
num = 0
for i in a:
	if i%2==0: num+=1
print(3**n-2**num)

Solution (Python):
n = int(input())
nums = list(map(int,input().split()))
count = 0
for num in nums:
  if num%2 == 0:
    count += 1
print(pow(3,n)-pow(2,count))

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
X=0
Y=0
for i in range(N):
    if A[i]%2==0:
        X+=1
    else:
        Y+=1
print(3**N-2**X)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
c = 1
for i in A:
    if i%2==1:
        c *= 1
    else:
        c *= 2
print(3**N - c)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c = 1
for i in a:
    if i%2 == 0:
        c*=2
print(3**n-c)

Solution (Python):
N = int(input())

A = list(map(int,input().split()))[:N]

def J(x,y):
    ans = 1
    for i in range(y):
        ans *= x
    return ans

L = len(A)
E = len(list(filter(lambda x:x%2==0,A)))

print(J(3,L)-J(2,E))

Solution (Python):
import sys
from collections import Counter

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 3 ** n
ahj = 0
for i in range(n):
	if a[i] % 2 == 1:
		ahj += 1
if ahj == 0 or ahj == n:
	ah = max(1, 2 ** (n - ahj) )
else:
	ah = (2 ** (n - ahj))
print(ans-ah)

Solution (Python):
from itertools import product


def main():
    N = int(input())
    A = map(int, input().split())

    f(N, A)


def f2(N, A):
    """
    Bの項どれか1つは偶数
    B = A, A+1, A-1
    Aの項が奇数: Bは奇数1,偶数2
    Aの項が偶数: Bは奇数2,偶数1
    B1が偶数なら、B2以降は似ていればなんでも良い
    B1が奇数なら、B2以降のどれかは似ていいるかつ偶数

    全列挙しなくてもAの項の偶奇性を使ってO(N)で計算できそう
    """
    pass


def f(N, A):
    """全組み合わせ

    3^10=59,049
    """
    B = [
        (a, a+1, a-1)
        for a in A
    ]
    ans = 0
    for b in product(*B):
        p = 1
        for _b in b:
            p *= _b
        if p % 2 == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
allp = 3 ** n
nop = 1
for i in range(n):
	if a[i] % 2 == 0:
		nop *= 2

print(allp - nop)

Solution (Python):

if __name__ == "__main__":
    N = int(input())
    a = list(map(int, input().split()))
    even = 0
    for factor in a:
        if factor%2 == 0:
            even += 1
        else:
            pass
    else:
        print(3**N-2**even)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
cou=0
for i in A:
    if i%2==0:
        cou+=1
print((3**N)-(2**cou))

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
even=0
for i in range(N):
  if A[i]%2==0: even+=1

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

Solution (Python):
import numpy

n = int(input())
l = map(int, input().split())

a = numpy.array([2 if i%2==0 else 1 for i in l])

print(3**n - a.prod())

Solution (Python):
n = int(input())
ret = 1
a = list(map(int,input().split()))
for i in a:
    if i%2==0:
        ret *= 2
 
print(3**n-ret)

Solution (Python):


def f(n, vals):
    return 3**n - 2**(sum(x%2==0 for x in vals))
    

def test():
    assert f(2, [2, 3]) == 7
    assert f(3, [3, 3, 3]) == 26
    assert f(10, [90, 52, 56, 71, 44, 8, 13, 30, 57, 84]) == 58921

def main():
    n = int(input())
    vals = map(int, input().split())
    
    print(f(n, vals))
    

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
counter = 0

def Num_of_even(list):
    num = 0
    for i in list:
        if i % 2 == 0:
            num += 1
        else:
            continue
    return num

all = 3 ** N
Not = 2 ** (Num_of_even(A))
print(all - Not)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

all_sym_pattern = 3**N
all_not_sym_pattern = 1

for i in range(N):
    if A[i] % 2 == 0:
        all_not_sym_pattern = all_not_sym_pattern * 2
    else:
        all_not_sym_pattern = all_not_sym_pattern * 1
        
print(all_sym_pattern - all_not_sym_pattern)

Solution (Python):
n = input()
l=map(int, raw_input().split())
c = 1
for i in l:
	if i%2==0:
		c*=2
print pow(3,n)-c

Solution (Python):

if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        c_total *= 3
        if a % 2 == 0:
            c_odd *= 2
    print c_total - c_odd

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 3**N
num = 1
for i in A:
    if i%2 == 0:
        num *= 2
print( ans-num )

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
count=1
odd=1
for i in a:
    if i % 2 ==0:
        count *= 3
        odd *= 2
    else:
        count *= 3

print(count-odd)

Solution (Python):

n = int(input())
q = [int(x) for x in input().split()]
nodd = 0
for i in q:
	if i&1:
		nodd += 1
print(pow(3,n)-pow(2,n-nodd))

Solution (Python):
n=input()
a=map(int,raw_input().split())
ans=3**n
rem=1
for v in a:
    if v%2==0: rem*=2
ans-=rem
print ans

Solution (Python):
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)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for x in a:
    if x%2 == 0:
        ans *= 2
print(3**n - ans)

Solution (Python):
num = input()
num = 3**int(num) 
data = input().rstrip().split(" ")
c=1
for i in data:
    if int(i) % 2 == 0:
        c *= 2
print(num-c)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
res = 3 ** n
mul = 1
for x in a:
    if x & 1:
        mul *= 1
    else:
        mul *= 2
print(res - mul)

Solution (Python):
n=int(input())
a=len([0 for x in input().split() if int(x)%2==0])
print(3**n-2**a)

Solution (Python):
N = int(input())
A = input()

arr = [int(a) for a in A.split(' ')]
odd_arr = []

for num in arr:
    if num % 2 == 0:
        odd_arr.append(2)
    else:
        odd_arr.append(1)

odd = 1
for num in odd_arr:
    odd = odd * num

print(3 ** N - odd)

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
ans=1
for i in [2 if n%2==0 else 1 for n in arr]:
    ans*=i
ans=3**n-ans
print(ans)

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

Solution (Python):
def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]

    for i in range(n):
        if i == 0:
            if a_list[i] % 2 == 0:
                tmp = 2
                continue
            else:
                tmp = 1
                continue
        if a_list[i] % 2 == 0:
            tmp *= 2

    print(3**n - tmp)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
oddcount = 0
for i in range(n):
	if a[i] % 2 == 1:
		oddcount += 1
answer = 3 ** n - 2 ** (n - oddcount)
print(answer)

Solution (Python):
N = int(input())
t = 1
for i in map(int, input().split()):
    if i % 2 == 0:
        t *= 2
print(3**N-t)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    ans = 3 ** N
    o = 1
    for a in A_list:
        if a % 2 == 0:
            o *= 2
        else:
            o *= 1
    print(ans - o)


if __name__ == '__main__':
    main()

Solution (Python):



N = int(input())
even = len(list(filter(lambda x: x%2==0,map(int,input().split()))))
print(3**N- (2**even)*1**(N-even))

Solution (Python):
N=input()
a=list(map(int,raw_input().split()))

x=1
for i in a :
	if i%2==0:
		x*=2


print pow(3,N)-x

Solution (Python):
from sys import stdin
def readLine_int_list():return list(map(int, stdin.readline().split()))

n = int(input())
a = readLine_int_list()
even = [i for i in a if i%2 == 0]
e = len(even)

if e == 0:
    if n == 1:
        print(2)
    else:
        print(3**n - 1)
else:
    print(3**n - (2**e))

Solution (Python):
N = int(input())
s = [int(i) for i in input().split()]

even = 0
odd = 0
for i in s:
    if i % 2 == 0:
        even += 1
print((3 ** len(s)) - (2 ** even))

Solution (Python):




"""








"""
from functools import reduce
from itertools import repeat


def multipler(x, y):
    return x*y

def hundred_or_one(l: list):
    return [True if x == 100 else False for x in l]
    

def check_odds(l :list):
    return [True if x % 2 == 0 else False for x in l]

def check_hun(l: list):
    return [True if x == 100 else False for x in l]

def main(num, data:list):
    """
    >>> main(1, [2])
    1
    >>> main(1, [3])
    2
    >>> main(10, [90,52,56,71,44,8,13,30,57,84])
    58921
    >>> main(2, [2,3])
    7
    >>> main(2, [100,100])
    3
    >>> main(1, [100])
    1
    >>> main(2, [1,1])
    8
    >>> main(1, [1])
    2
    >>> main(2, [1,2])
    7
    >>> main(2, [1,3])
    8
    >>> main(2, [1,100])
    5
    >>> main(3, [1,1,100])

    >>> main(3, [1,100,100])
    """
    hun_one = hundred_or_one(data)
    odds = check_odds(data)  
    huns = check_hun(data)

    basis = [3 for t in hun_one]

    
    remover = [2 if o else 1 for o in odds]

    remover_num = int(reduce(multipler, remover))
    
    

    basic_answer = reduce(multipler, basis)
    
    
    return basic_answer - remover_num

if __name__ == '__main__':
    
    
    num = int(input())
    data = input().split(" ")
    data = [int(i) for i in data]

    print(main(num, data))

Solution (Python):
from sys import stdin
cur = 1
n = int(stdin.readline())
a = map(int,stdin.readline().split())
total = 1
for i in a:
 if i%2==0:
  cur*=2
 total*=3
print total - cur

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

num = 0
for Ai in A:
    if Ai % 2 == 0:
        num += 1

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 3 ** n
ahj = 0
for i in range(n):
	if a[i] % 2 == 1:
		ahj += 1
if ahj == 0 or ahj == n:
	ah = max(1, 2 ** (n - ahj) )
else:
	ah = (2 ** (n - ahj))
print(ans-ah)

Solution (Python):

def inpl(): return tuple(map(int, input().split()))

N = int(input())
A = inpl()

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

Solution (Python):
n = int(input())
a = input().split()

ans = 1
sub = 1

for i in range(n):
	ans *= 3

for i in a:
	if int(i)%2 == 0:
		sub *= 2

print(ans - sub)

Solution (Python):
import numpy as np
import itertools
if __name__ == "__main__":
    digit=int(input())
    values=[int(x) for x in input().split(' ')]
    cnt=0
    values_neighbor=['']*digit
    for i in range(0,len(values_neighbor)):
        values_neighbor[i] = (values[i]-1, values[i], values[i]+1)

    pare_list=list(itertools.product(*values_neighbor))

    pare=[np.array(x).prod() for x in pare_list]
    for x in pare:
        if x%2==0:
            cnt=cnt+1
    print(cnt)

Solution (Python):
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()

Solution (Python):
a=input()
b=map(int,raw_input().split())

odd=0
for i in b:
    if i%2==1:
        odd+=1

ans=3**a-2**(a-odd)

print ans

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
d=1
u=3**N
for i in range(N):
    if A[i]%2==0:
        d*=2
u-=d
print(u)

Solution (Python):
s=1
N=int(input())
for i in range(1,2):
    A= [int(i) for i in input().split()]
for i in range(len(A)):
    if A[i] %2 == 0 :
        s = s * 2
    else :
        s = s * 1
print(3**N-s)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    even_count = 0
    odd_count = 0
    for a in A:
        if a % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
    print(3 ** N - (2 ** even_count))

Solution (Python):

num = int(input())
value = input().split()

value = [int(x) for x in value]

cnt = []

res = pow(3, len(value))
for i in range(0, len(value)):
    if value[i] % 2 == 0:
        cnt.append(2)
    else:
        cnt.append(1)

ss = 1
for i in cnt:
    ss = ss * i
print(res-ss)

Solution (Python):
N = int(raw_input())
A = map(int, raw_input().split())

sim = 1
odd = 1
for i in xrange(N):
  ai = A[i]
  sim *= 3
  if ai % 2 == 0:
    odd *= 2

print sim - odd

Solution (Python):
def spaceinput():
    return list(map(int,input().split(" ")))



N=int(input())
a=spaceinput()


v=1
for sa in a:
    if sa%2==0:
        v*=2


print(3**N-v)

Solution (Python):

import itertools

N = int(input())
pre_num_list = [int(i) for i in input().split()]
num_list = [[i-1, i, i+1] for i in pre_num_list]
target_list = list(itertools.product(*num_list))
counter = 0
odd_flag = 0
for item in target_list:
    even_flag = False 
    for each_num in item:
        if even_flag == False:
            if each_num % 2 == 0:
                even_flag = True
        else:
            continue
    if even_flag == True:
        counter += 1
    
print(counter)

Solution (Python):
import itertools

inputs = input()
N = int(inputs)


inputs = input().split()
A = map(lambda x: int(x), inputs)

count = 1
for i in A:
    if i % 2 == 0:
        count = count * 2
        
print(3**N - count )

Solution (Python):



"""code-fes-2017-qual-c-b"""


import sys

from functools import reduce

def solve(str):
    """Solve."""
    i = int(str)

    if i % 2 == 0:
        return 2
    else:
        return 1


def main():
    """Main function."""
    N = int(input())
    As = map(solve, input().split())
    comp = reduce(lambda a, b: a * b, As)

    print(pow(3, N) - comp)


if __name__ == '__main__':
    sys.exit(main())

Solution (Python):
length, count = int(input()), 0
num = input()
num = [int(x) for x in num.split(" ")]

for i in num:
  if i % 2 == 0:
    count += 1 

print(3 ** length - 2 ** count)