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):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

from functools import reduce
ans=0
n=I()
a=LI()
ans=3**n-reduce(lambda x,y:x*y,[2-i%2 for i in a])
print(ans)

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

al = 3 ** n
sub = 1

for i in range(n):
    if ls[i] % 2 == 0:
        sub = sub * 2

print(al - sub)

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

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

tot = 3 ** N

cnt_odd, cnt_even = 0,0

for i in range(N):
	if A[i] % 2 == 0:
		cnt_even += 1
	else:
		cnt_odd += 1

ans = tot - (2**cnt_even)*(1**cnt_odd)
print(ans)

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
ans=(3**n)-2**cnt
print(ans)

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

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

Solution (Python):
def main():
  import numpy as np
  N = int(input())
  A = list(map(int,input().split()))

  def ternary (n):
      if n == 0:
          return '0'
      nums = []
      while n:
          n, r = divmod(n, 3)
          nums.append(str(r))
      return ''.join(reversed(nums))

  ans = 0
  AA = np.array(A)
  for i in range(3**N):
    I = ternary(i).zfill(N)
    tmp = 1
    for a in range(N):
      if I[a] == "0":
        tmp *= AA[a] - 1
      elif I[a] == "1":
        tmp *= AA[a]
      else:
        tmp *= AA[a] + 1
    if tmp % 2 == 0:
      ans += 1
  print(ans)
main()

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

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

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

whole = 3 ** n
odds = 1
for i in a:
    if i & 1:
        odds *= 1
    else:
        odds *= 2

print(whole-odds)

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

Solution (Python):
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

a = 3**len(li)
point = 1
for i in li:
    if i % 2 == 0:
        point*=2

print(a-point)

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

x = list(itertools.product([-1,0,1 ],repeat=n))
ans = 0
for i in x:
    for j in range(n):
        if (a[j] + i[j]) % 2 == 0:
            ans += 1
            break
print(ans)

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

ans = 3**n

temp = 1
for i in a:
    if i % 2 == 0:
        temp*=2
ans -= temp
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):
N = int(input())
A = [int(i) for i in input().split()]

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

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

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

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

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):
n = int(input())
List = list(map(int,input().split()))
odd = [1 for _ in range(n)]
for item in List:
  if item % 2 == 0:
    odd.append(2)
  else:
    odd.append(1)
odd_factor = 1
for item in odd:
  odd_factor *= item
Answer = 3**n -odd_factor
print(Answer)

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

Solution (Python):
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  

N = ri()
A = np.array(rl())
count = 3 ** N
even_num = A[A%2 == 0].size
answer = count - 2 ** even_num
print(answer)

Solution (Python):

import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    ans = 1
    t = 1
    for i in range(N):
        t *= 3
        if A[i]%2 == 0:
            ans *= 2
        
    print(t-ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    ans = 1
    t = 1
    for i in range(N):
        
        
        

        t *= 3
        if A[i]%2 == 0:
            ans *= 2
        
    print(t-ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

N = int(input())
a = list(map(int, input().split()))
b = [0] * N
ans = 0

def dfs(v):
    global ans
    if v == N:
        tmp = 1
        for i in b:
            tmp *= i
        if tmp % 2 == 0:
            ans += 1
        return

    b[v] = a[v] - 1
    dfs(v + 1)
    b[v] = a[v]
    dfs(v + 1)
    b[v] = a[v] + 1
    dfs(v + 1)
    return

dfs(0)
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for a in A:
        if a % 2 == 0:
            cnt += 1

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


main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
num_even = 0
for a in A:
    if a % 2 == 0:
        num_even += 1
print(pow(3, len(A)) - pow(2, num_even))

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

Solution (Python):
import itertools
import numpy as np
from sys import stdin
N = int(stdin.readline().rstrip())
A = np.array([int(_) for _ in stdin.readline().rstrip().split()])
products = list(itertools.product([0, 1, -1], repeat=N))
ans = 0
for p in products:
    if np.prod(A - np.array(p)) % 2 == 0:
        ans += 1
print(ans)

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

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

odd = 0
even = 0

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

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=3**N-2**sum([Ai%2==0 for Ai in A])

print(ans)

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

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

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

c = 0
for a in A:
  if a%2 == 0:
    c += 1

print(3**n-2**c)

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

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

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

Solution (Python):
n,*a=map(int,open(0).read().split());print(3**n-2**sum(~i%2for i in a))

Solution (Python):
n,*a=map(int,open(0).read().split())
b=sum(i%2 for i in a)
print(3**n-2**(n-b))

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

res = 1
for a in A:
    res *= 2 if a % 2 == 0 else 1

print(3 ** N - res)

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

s = 3**n

t = 1

for x in a_li:
    if x%2 == 0:
        t *= 2
    else:
        t *= 1
        
print(s-t)

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

a = [i % 2 for i in A]
even = a.count(0)
odd = N - even

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

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = 1
for i in a:
    if i%2==0:
        res *= 2
print(3**n - res)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
even=0
for p in a:
  even+=(p%2==0)
print(3**n-2**even)

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

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

all=3**n
oddgr=2**even
print(all-oddgr)

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

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

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

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

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
print(3 ** n - 2 ** np.sum(a % 2 == 0))

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
print(3**n-2**np.sum(-1*(a % 2 - 1)))

Solution (Python):
from itertools import product

N = int(input())
A = list(map(int, input().split()))
ans = 0

for mask in product([-1, 0, 1], repeat=N):
    prd = 1
    for (a, d) in zip(A, mask):
        prd *= (a + d)
    if prd % 2 == 0:
        ans += 1

print(ans)

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

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
N = ni()
A = nl()

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

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):
N=int(input())
A=list(map(int,input().split()))
ans=3**N
X=1
for i in range(N):
  if(A[i]%2==0):
    X*=2
ans-=X
print(ans)

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

cnt = 1
for a in A:
    if a % 2 == 0:
        cnt = cnt*2

print(3**n - cnt)

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

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

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

e = 0
o = 0
for i in a:
    if i % 2 == 0:
        e += 1
    else:
        o += 1 

ans = 3 ** len(a) - (2 ** e) * (1 ** o) 
print(ans)

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
A = np.array(A, dtype=int)

print(3 ** N - (1 + (A % 2 == 0)).prod())

Solution (Python):
import itertools
import numpy as np
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A = np.array(A)
ans = 0
for i in list(itertools.product([0,1,-1],repeat=N)):
    if np.prod(A + np.array(i)) % 2 == 0:
        ans += 1
print(ans)

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

Solution (Python):
n=int(input())
a = list(map(int,input().split()))	
odd = 0
even = 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())
A = list(map(int,input().split()))
cntEven = 0
cntOdd = 0
for a in A:
    if a%2 == 0:
        cntEven += 1
    else:
        cntOdd += 1
print(3**N - 2**cntEven)

Solution (Python):
n = int(input())
cnt = 1
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)

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

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

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

ans = 3 ** n - 2 ** even
print(ans)

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

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

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


def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    print(3 ** n - reduce(mul, [1 if ai % 2 else 2 for ai in a]))


if __name__ == "__main__":
    resolve()

Solution (Python):
def solve(n, a):
    ans = 1
    for i in range(n):
        ans *= 2 if (a[i] % 2 == 0) else 1
    return 3 ** n - ans

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Solution (Python):


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

cnt=1
for e in a:
    if e%2:
        cnt*=1
    else:
        cnt*=2
print(3**n-cnt)

Solution (Python):
N=int(input())
A=list(map(lambda x: 1 if int(x)%2==0 else 0,input().split()))


print(3**N-2**sum(A))

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

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

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

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

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

Solution (Python):
def main():

    N = int(input())
    A = list(map(int, input().split()))
    odd = 1
    for a in A:
        if a % 2 == 0:
            odd *= 2
    return pow(3, len(A)) - odd
    
if __name__ == '__main__':
    print(main())

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

Solution (Python):





from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

def dextothree(m):
    s=""
    tmp=m
    while tmp>0:
        s+=str(tmp%3)
        tmp//=3
    return s[::-1]
 
n=int(input().rstrip())
a=[int(i) for i in input().split()]
num=[]
ans=0
for i in range(n):
    num.append([a[i]-1,a[i],a[i]+1])

for i in range(3**n):
    now=dextothree(i).zfill(n)
    
    cnt=1
    for i in range(n):
        cnt*=num[i][int(now[i])]
    if cnt&1==0:
        ans+=1
print(ans)

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

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

Solution (Python):
import functools, operator

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

d = functools.reduce(operator.mul, (2 if v % 2 == 0 else 1 for v in a), 1)
print(3 ** n - d)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
X=[[1]*3 for i in range(10)]

for i in range(N):
   X[i][0]=A[i]-1
   X[i][1]=A[i]
   X[i][2]=A[i]+1
ans=0
for a in X[0] :
    if N==1:
        if a%2==0:
            ans+=1
    for b in X[1]:
        if N<2:
            break
        elif N==2:
            if (a*b)%2==0:
                ans+=1
        for c in X[2]:
            if N<3:
                break
            elif N==3:
                if (a*b*c)%2==0:
                    ans+=1
            for d in X[3]:
                if N<4:
                    break
                elif N==4:
                    if (a*b*c*d)%2==0:
                        ans+=1
                for e in X[4]:
                    if N<5:
                        break
                    elif N==5:
                        if (a*b*c*d*e)%2==0:
                            ans+=1
                    for f in X[5]:
                        if N<6:
                            break
                        elif N==6:
                            if (a*b*c*d*e*f)%2==0:
                                ans+=1
                        for g in X[6]:
                            if N<7:
                                break
                            elif N==7:
                                if (a*b*c*d*e*f*g)%2==0:
                                    ans+=1
                            for h in X[7]:
                                if N<8:
                                    break
                                elif N==8:
                                    if (a*b*c*d*e*f*g*h)%2==0:
                                        ans+=1
                                for i in X[8]:
                                    if N<9:
                                        break
                                    elif N==9:
                                        if (a*b*c*d*e*f*g*h*i)%2==0:
                                            ans+=1
                                    for j in X[9]:
                                        if N<10:
                                            break
                                        elif N==10:
                                            if (a*b*c*d*e*f*g*h*i*j)%2==0:
                                                ans+=1

print(ans)

Solution (Python):
N=int(input())
A=[int(i) for i 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()))

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

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

odd_pat=1
for aa in a:
    if aa%2==0:
        odd_pat*=2
    else:
        odd_pat*=1
print(3**n-odd_pat)

Solution (Python):
N,*A=map(int,open(0).read().split());l=1
for a in A:l*=2-(a%2)
print(3**N-l)

Solution (Python):
n = int(input())
import numpy as np
a = np.array([int(i) for i in input().split()])
print(3**n - 2**len(a[a%2 == 0]))

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

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

print(3 ** N - num)

Solution (Python):
print(3**int(input())-2**sum(int(i)%2<1 for i in input().split()))

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

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

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

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

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

Solution (Python):

n = int(input())
num_list = [ int(v) for v in input().split() ]
dp_list = [ 0 for i in range(n) ]
for i, v in enumerate(num_list):
    if i == 0:
        if v % 2 == 0:
            dp_list[i] = 1
        else:
            dp_list[i] = 2
    else:
        if v % 2 == 0:
            dp_list[i] += 2 * dp_list[i-1] + 3**i 
        else:
            dp_list[i] += dp_list[i-1] + 2 * 3**i 
print(dp_list[-1])

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

n_kisuuretsu=2**sum([item%2==0 for item in a])

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

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

print(3 ** N - 2 ** sum(a % 2 == 0 for a in A))

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())
odd = 1
for i in input().split():
  odd *= 1 if int(i) % 2 else 2
print(3**n - odd)

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

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

even = 0
for i in range(N):
    if a[i]&1 == 0:
        even += 1


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

Solution (Python):
import sys
import collections
import copy
input = sys.stdin.readline
N = int(input())
a =list(int(i) for i in input().split())
chk = 1
for i in range(N):
    if a[i]%2 == 0:
        chk *= 2
print(3**N -chk)

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

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

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

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

for i in range(N):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1

if even == 0:
    ans = 3 ** N - 1
else:
    ans = 3 ** N - 2 ** even

print(ans)

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

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

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

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

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

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

tmp = 1
for i in range(N):
    if a[i]&1 == 0:
        tmp *= 2
print(3**N - tmp)

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


N = ii()
As = list(mi())

oddans = 1
for a in As:
  if a % 2 == 1:
    
    continue
  else:
    
    oddans *= 2

print(pow(3, N) - oddans)

Solution (Python):
n = int(input())
a = [int(item) for item in input().split()]
total = 1; odd = 1
for item in a:
    total *= 3
    if item % 2 == 0:
        odd *= 2
    else:
        odd *= 1
print(total - odd)

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

odd_num = 0
for a in A:
	odd_num += (0 == a % 2)

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

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

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

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

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
ans=3**n
subd=1
for i in range(n):
  subd*=(2-l[i]%2)
print(ans-subd)

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

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

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

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

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

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

N = int(input())
*A, = 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)

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

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

Solution (Python):
from functools import *
print(3 ** int(input()) - reduce(lambda x,y: x*y, (1 if i % 2 == 1 else 2 for i in map(int, input().split()))))

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

odds = 1
for i in A:
    odds *= 1 if i % 2 == 1 else 2

print(3 ** N - odds)

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

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

print(all - odd)

Solution (Python):
N = int(input())
odd = 1
for a in input().split():
  a = int(a)
  if a % 2 == 0:
    odd *= 2

answer = 3 ** N - odd
print(answer)

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
a = LI()
evencnt = 0
oddcnt = 0
for num in a:
    if num % 2 == 0:
        evencnt += 1
    else:
        oddcnt += 1
print((3 ** n) - (2 ** evencnt))