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()))

from itertools import product

li = [-1,0,1]
cnt = 0
for v in product(li,repeat = n):
    L = []
    for i in range(n):
        L.append(v[i]+a[i])
    if any(x%2==0 for x in L):
        cnt +=1

print(cnt)

Solution (Python):
import numpy as np
from itertools import product

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

a = np.array(a)

li = [-1,0,1]
cnt = 0
for v in product(li,repeat = n):
    v = np.array(v)
    L =a+v
    cum = L.cumprod()
    if cum[-1]%2 ==0 :
        cnt +=1
print(cnt)

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


resolve()

Solution (Python):
from itertools import product
import numpy as np
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ls = []
    for i in range(N):
        ls.append([A[i], A[i]+1, A[i]-1])
    
    ls = list(product(*ls))
    ans = len(ls)
    for a in ls:
        if np.prod(a) % 2 == 1:
            ans -= 1

    print(ans)

    return

resolve()

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

even_num = 0

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

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

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

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

all_num = 3 ** N
even = 1

for a in A:
    if a % 2 == 0:
        even *= 2

print(all_num - even)

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    even = sum([a % 2 == 0 for a in A])
    print(pow(3, n) - pow(2, even))


if __name__ == '__main__':
    main()

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

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

total = pow(3, N)
odd = 1
for i in range(N):
    if A[i] % 2 == 0:
        odd *= 2
    else:
        odd *= 1
ans = total - odd
print(ans)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

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

    print(3 ** N - all_odd)

if __name__ == '__main__':
    resolve()

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union































def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    
    n = ii()
    L = lmi()
    odd_count = 1
    for i in range(n):
        if L[i] % 2 == 0:
            odd_count *= 2
    print(pow(3, n) - odd_count)


if __name__ == "__main__":
    main()

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

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

a = 3 ** N

e = [i % 2 == 0 for i in A].count(True)

print(a-2**e)

Solution (Python):
from itertools import product

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

count = 0
for diffs in product((-1, 0, 1), repeat=N):
    for a, d in zip(A, diffs):
        if (a % 2 == 0 and d == 0) or (a % 2 == 1 and d != 0):
            count += 1
            break

print(count)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
A = l()
mi = 0

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

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

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

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
ans-=tmp
print(ans)

Solution (Python):
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()
sum_a = 3**n
pro = 1
for i in a:
	if i%2==0:
		pro*=2
print(sum_a-pro)

Solution (Python):

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

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

x = 1

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

print(3**n - x)

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

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

print(3**n - c)

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

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

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

odd_count = 1

for a in A:
  if a%2 == 0:
    odd_count *= 2

print(3**N - odd_count)

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

odd_count = 1

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

print(3**N - odd_count)

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

def main(n,a):
    evena=[False]*n
    for i in range(n):
        if a[i]%2==0:
            evena[i]=True
    count=0
    for i in range(3**n):
        
        neven=0
        for bit in range(n):
            mask=3**bit
            if (i//mask)%3 == 0:
                
                if evena[bit]==False:
                    neven+=1
            elif (i//mask)%3 == 1:
                
                if evena[bit]==True:
                    neven+=1
            elif (i//mask)%3 == 2:
                
                if evena[bit]==False:
                    neven+=1
            
                
        if neven>0:
            count+=1
    return count

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
A = LIST()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
A = LIST()

a = [2 - x%2 for x in A]
odd = 1
for x in a:
	odd *= x

print(3**N - odd)

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    all = 1
    cnt = 1
    for i in range(n):
        all *= 3
        if a[i]%2 == 0:cnt *= 2
    print(all-cnt)

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

B = [a-1 for a in A]
C = [a+1 for a in A]


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

count = 0
for i in range(3**N):
    i3 = Base_10_to_n(i, 3).zfill(N)
    Pick = []
    for j in range(N):
        if i3[j] == '0':
            Pick.append(A[j])
        elif i3[j] == '1':
            Pick.append(B[j])
        elif i3[j] == '2':
            Pick.append(C[j])

    if any([p%2 == 0 for p in Pick]):
        count += 1
print(count)

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

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

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

Solution (Python):
import sys

def dfs(x,m,nex):
    if m==n:
        
        if x%2==0:
            global ans
            ans += 1
    else:
        ai = a[nex]
        m += 1
        nex += 1
        for i in (ai,ai-1,ai+1):
            dfs(x*i,m,nex)

sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in (a[0],a[0]-1,a[0]+1):
    dfs(i,1,1)
print(ans)

Solution (Python):


def main():
    base_array=[]
    similar_array=[]
    odd_num_array=[]
    counter=0
    ans=1
    array_length = int(input())
    base_array=list(map(int,input().split()))
    for i in base_array:
        data = [i-1,i,i+1]
        similar_array.append(data)
    for array in similar_array:
        for i in array:
            if i % 2 !=0:
                counter+=1
        odd_num_array.append(counter)
        counter=0
    for number in odd_num_array:
        ans*=number
    print(3**array_length-ans)

if __name__=="__main__":
    main()

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

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

print(ans-cnt)

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

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



def main():
    N = int(input().strip())
    A = [int(i) for i in input().strip().split()]
    odds = 1
    for a in A:
        if a % 2 == 0:
            odds *= 2
        else:
            continue

    return 3**N - odds


if __name__ == "__main__":
    print(main())

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

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

tmp = 1
for aa in A:
	if aa%2 == 0:
		tmp *= 2
	else:
		tmp *= 1



print(3**N-tmp)

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
ans = 3**n
x = 1

for i in li:
    if i%2 == 0:
        x *= 2

print(ans-x)

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

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
print(ans - x)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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 make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

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

Solution (Python):


import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, *A = map(int, read().split())

res = pow(3, N)
odd = 1

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

print(res - odd)

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

cnt = 1
for i in A:
    if not i%2:
        cnt *= 2

print(3**N-cnt)

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

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


if __name__ == '__main__':
    main()

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

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

count=0
for a in A:
    count+=1*(a%2==0)

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

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

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

al = 1
bad = 1

for a in A:
    al *= 3
    if a % 2 == 0:
        bad *= 2

print(al - bad)

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

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

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()))
res = 3**N
odd_cnt = 0
for i in A:
    if i%2 == 0:
        odd_cnt += 1
print(res - 2**odd_cnt)

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

Solution (Python):
import sys

input = sys.stdin.readline


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

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

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


if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

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()))
print(3 ** N - 2 ** sum([1 for i in A if not i % 2]))

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

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

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

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

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

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

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

Solution (Python):



n = int(input())
nums = [int(i) for i in input().split()]

odd = 0
even = 0
for num in nums:
    if num % 2 == 0:
        even += 1
    else:
        odd += 1

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

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

n = int(input())
a = list(map(int, input().split()))
k = [2 if i % 2 == 0 else 1 for i in a]

count = 3**len(a) - reduce(mul, k)

print(count)

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

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

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

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

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

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
odds = len([1 for x in a if x % 2 == 0])

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

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


ans = 0


def solve(i, l):
    global ans

    if len(l) == n:
        total = 1
        for k in l:
            total *= k
        if total % 2 == 0:
            ans += 1
        return

    for j in range(-1, 2):
        l.append(a[i] + j)
        solve(i + 1, l)
        l.pop()


solve(0, [])
print(ans)

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

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

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

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

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

    print(3**N - res)


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()))
c = 1
for a in A:
    if a % 2 == 0:
        c *= 2
print(3**N-c)

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 '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')


print('abc', end='')
print('xyz')

source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    n=int(input())
    
    
    
    
    
    nl=list(map(int, input().split(" ")))
    times=1
    for i in range(n):
        if nl[i]%2==1:
            times=times*1
        else:
            times=times*2
    print(3**n-times)

    
    
    


    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()))

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

print((3**n)-cnt)

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

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