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):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



def func(a, n, i, p):
    if i == n:
        if p % 2 == 0:
            return 1
        return 0
    return func(a, n, i + 1, p * (a[i] - 1)) + func(a, n, i + 1, p * a[i]) + func(a, n, i + 1, p * (a[i] + 1))



n = int(input())    
a = list(map(int, input().split()))        
ans = func(a, n, 0, 1)
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 = list(map(int, input().split()))





even_list = [x for x in A if x%2 == 0]
ans = 3**len(A) - 2**(len(even_list))
print(ans)

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

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

Solution (Python):
from itertools import product

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

s = sum(any(map(lambda x: x % 2 == 0, (u + v for u, v in zip(A, list(x)))))
        for x in product((-1, 0, 1), repeat=N))
print(s)

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

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    n=int(input())
    
    
    
    nl=list(map(int, input().split(" ")))
    sum=0
    times=1
    even_lis=[0]*n
    odd_lis=[0]*n
    for i in range(n):
        if nl[i]==1:
                even_lis[i]=1
                odd_lis[i]=1
        if nl[i]%2==0:
                even_lis[i]=1
                odd_lis[i]=2
        else:
            even_lis[i]=2
            odd_lis[i]=1
    for i in range(n):
     
        times=times*(odd_lis[i])
    sum=3**n-times
     
    

    
    

    '''
        if nl[i]%2==0:
            sum=sum+3**(len(nl[i:])-1)
        elif nl[i]%2==1:
            sum=sum+2*3**(len(nl[i:])-1)
    '''
    print(sum)
    
    
    
    
    
    


    for i in range(1,n+1,2):
     pass
     

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')
    
    
    
    

    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

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

def judge(i, nums):
    global ans
    if i == n:
        m = 1
        for j in range(n):
            m *= nums[j]
        
        if m % 2 == 0:
            ans += 1
    else:
        nums[i] = a[i] - 1
        judge(i + 1, nums)
        nums[i] = a[i]
        judge(i + 1, nums)
        nums[i] = a[i] + 1
        judge(i + 1, nums)
        
nums = [0] * n
judge(0, nums)
print(ans)

Solution (Python):
import numpy as np

def dfs(A, a, n, ans):
  if len(A) == n:
    tmp = np.array(A) + a
    if sum(tmp % 2) < len(A):
      ans += 1
    return ans
  
  for i in range(-1, 2):
    A.append(i)
    ans = dfs(A, a, n, ans)
    A.pop()
    
  return ans

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

print(dfs([], a, n, 0))

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

tmp = (A%2==0).sum()

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

Solution (Python):
import math
import copy

n = int(input())
a = [int(x) for x in input().split()]
neko = 3 ** n
nya = 1
for i in a:
    if i%2 == 0:
        nya *= 2
print(neko-nya)

Solution (Python):
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
ans = 0
for x in [x for x in itertools.product([-1,0,1],repeat=N)]:
    calc = 1
    for i in range(N):
        calc *= A[i]+x[i]
    if calc%2==0:
        ans += 1
print(ans)

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

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

def f(i, v):
    if i == n:
        return any(x % 2 == 0 for x in v)

    ans = 0
    for d in (-1, 0, 1):
        v_ = v[:]
        v_.append(A[i]+d)
        ans += f(i+1, v_)

    return ans

print(f(0, []))

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

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

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

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

ans = 3**n
aa = 1
for i in A:
    if i%2==0:aa*=2

print(ans-aa)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=1
    for i in l:
        if i%2==1:
            cnt*=1
        else:
            cnt*=2
    print(3**n-cnt)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    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)
    
resolve()

Solution (Python):

import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)

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

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

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

print(ans)

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
kisu = 1

for i, a in enumerate(A):
    if a % 2 == 0:
        kisu *= 2
    else:
        kisu *= 1
print(3 ** N - kisu)

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:
  total = 3**n
  evens = 0
  for x in a:
    if x%2==0:
      evens += 1
  exceptns = 2**evens
  print(total-exceptns)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

def resolve():
    N=int(input())
    t=3**N
    s=1
    f=0
    for a in pin():
        if  a%2:
            f=1
            s*=1
        else:
            s*=2

    print(t-s)

resolve()

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

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

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

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    cunt=0
    for a in A:
        if a%2==0:cunt+=1
    print(3**n-2**cunt)

if __name__=='__main__':
    main()

Solution (Python):
n, *a_l= map(int, open(0).read().split())
odd = 1
for a in a_l:
    tmp_odd = 0
    for i in [a-1, a, a+1]:
        if i % 2 == 1:
            tmp_odd += 1
    odd *= tmp_odd
ans = 3**n - odd
print(ans)

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

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

Solution (Python):



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

all_pair = 1
odd_pair = 1

for i in range(n):
    if a_inputs[i]%2==0:
        odd_pair*=2
    else:
        odd_pair*=1
    all_pair*=3

print(all_pair-odd_pair)

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

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

cnt = 3 ** n - (2 ** (cnt_even))
print(cnt)

Solution (Python):
import sys
sys.setrecursionlimit(500*500)
n = int(input())
a = list(map(int, input().split()))
ans = 0

def dfs(i, p, sum):
    global ans
    if p == n:
        if sum % 2 == 0:
            ans += 1
    else:
        dfs(a[p], p+1, sum*a[p])
        dfs(a[p]+1, p+1, sum*(a[p]+1))
        dfs(a[p]-1, p+1, sum*(a[p]-1))

dfs(1, 0, 1)
print(ans)

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

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

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

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

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):
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

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

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

print(3**len(A)-2**odd)

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

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

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n = II()
    aa = MII()
    cnt = 3**n
    m = list(acc([2 if a%2==0 else 1 for a in aa ],lambda x,y: x*y))
    print(cnt-m[-1])


if __name__ == '__main__':
    main()

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

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

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

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

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


def count_simular_arrays(arr):
	ans = 0
	
	for a in arr:
		for n in a:
			if n % 2 == 0:
				ans += 1
				break

	return ans


import copy

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

for i in range(-1, 2):
	arr.append([a[0] + i])

for i in range(1, n):
	copied = copy.deepcopy(arr)
	arr.clear()
	
	for c in copied:
		for j in range(-1, 2):
			arr.append(c + [a[i]+j])

print(count_simular_arrays(arr))

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

ans = 3**N - 2**(len(even))
print(ans)

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

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

temp = 1
ans = 1
for a in A:
    if a % 2 == 0:
        temp *= 2
        ans *= 3
    else:
        temp *= 1
        ans *= 3

print(ans - temp)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

print(3**n-cnt)

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

ans = 1
for a in A:
    
    
    
        ans *= 3

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

print(ans-odd)

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

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

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

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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

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

if __name__ == '__main__':
    main()

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

cnt = 0
for ai in A:
    if ai % 2 == 0:
        cnt += 1
        
print(3**N-2**cnt)

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    lis = readInts()
    
    whole = 3 ** n
    ex = 1
    for x in lis:
        if x % 2 == 0:
            ex *= 2
    print(whole - ex)
if __name__ == '__main__':
  main()

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

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

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

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

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

Solution (Python):
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    bit = []
    for i in range(n):
        bit.append(list(range(A[i] - 1, A[i] + 2)))

    res = 0
    for pattern in product([0, 1, 2], repeat=n):
        value = 1
        for idx, i in enumerate(pattern):
            value *= bit[idx][i]

        if value % 2 == 0:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()

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

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

total = 3**n
ans = 1
for i in A:
    if i % 2 == 0:
        ans *= 2

print(total - ans)

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

Solution (Python):
n = int(input())
a = 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())
arr = list(map(int,input().split()))

ans = 1
out = 1
for i in range(n):
    if arr[i]%2 == 0:
        ans *= 3
        out *= 2
    else:
        ans *= 3
        out *= 1

print(ans-out)

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

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

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

ans = 3**n

if a[0] % 2 == 0:
    cnt = 2
else:
    cnt = 1
for i in range(1, n):
    if a[i] % 2 == 0:
        cnt *= 2
    else:
        pass

print(ans-cnt)

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

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

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

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

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

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

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