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()))
x = 1
for i in a:
    if i % 2 == 0:
        x *=2
    else:
        x *=1
ans = 3**n -x
print(ans)

Solution (Python):
import itertools
n = int(input())
a = list(map(int,input().split()))
b = [[0] * 3 for i in range(n)]
for i in range(n):
    b[i][0] = a[i] - 1
    b[i][1] = a[i]
    b[i][2] = a[i] + 1
c = list(itertools.product(*b))
cnt = 0
for i in range(len(c)):
    x = c[i][0]
    for j in range(1, n):
        x = x * c[i][j]
    if x % 2 == 0:
        cnt += 1

print(cnt)

Solution (Python):


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

    ans = 3 ** N - 2 ** e

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):









import os
import sys




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

    



if __name__ == "__main__":
    main()

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

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

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

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())
nums = list(map(int, input().split()))
even_cnt = 0
for num in nums:
  if num%2 == 0:
    even_cnt += 1
print(3**N-2**even_cnt)

Solution (Python):
import  itertools as it

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

cnt = 0
for Z in it.product(range(3),repeat=N):
  t = 1
  for z,a in zip(Z,A):
    t*=(a+z-1)
  if t%2 == 0:
    cnt+=1
print(cnt)

Solution (Python):
N,*A = map(int,open(0).read().split())

cnt = 0

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

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

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

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

Solution (Python):
def solve():
    N = int(input())
    E = [int(i) for i in input().split() if int(i) % 2 == 0]
    print(3 ** N - 2 ** len(E))

if __name__ == "__main__":
    solve()

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

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

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

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

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

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

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

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

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

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

Solution (Python):
from itertools import product

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

count = 0
for C in product((-1, 0, 1), repeat=n):
  total = 1
  for a, c in zip(A, C):
    total *= (a + c)
  if total % 2 == 0:
    count += 1
print(count)

Solution (Python):
from functools import reduce

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

n = reduce(lambda x, y: x * y, (1 if a % 2 else 2 for a in A))
print(3 ** N - n)

Solution (Python):
N = int(input())
even = sum([1 for i in input().split() if int(i)%2==0])
print(3**N-2**even if even!=0 else 3**N-1)

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

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

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

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

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

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

print(3 ** n - odd)

Solution (Python):
N=int(input())
A=list(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):
N=int(input())
A=tuple(map(int,input().split()))

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

print(3**N-sum)

Solution (Python):





def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())
    a_list = [int(x) for x in input().rstrip().split(" ")]

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

    print(3 ** len(a_list) - odd)



if __name__ == "__main__":
    resolve()

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

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

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

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 = 3**len(a)
cnt = 1

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

print(ans - cnt)

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

Solution (Python):
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    even_count = 0

    for a in a_list:
        if a % 2 == 0:
            even_count += 1

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    ans = 3 ** N
    excl = 1

    for x in A:
        if x % 2 == 0:
            excl *= 2

    ans -= excl

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
'''
Created on 2020/09/02

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

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

Solution (Python):
import numpy as np

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

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

ans = pow(3, n) - k

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
a = len(A)
t = 1 

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

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**N - cnt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
combiIncludingOdd = 3**len(A)

c = 1
for a in A:
    if a % 2 == 0:
        c*=2
print(combiIncludingOdd-c)

Solution (Python):

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

num_even = len([i for i in A if i % 2 == 0])
print(3 ** N - 2 ** num_even)

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

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









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

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

odd_pattern = [1 if A&1 else 2 for A in a]
all_odd = 1
for p in odd_pattern:
    all_odd *= p

print(3**n - all_odd)

Solution (Python):
print(3**int(input())-2**(sum(~l&1 for l in map(int,input().split()))))

Solution (Python):
n = int(input())
A = tuple(map(int, input().split()))
ans = 0
from itertools import product
for P in product([-1, 0, 1], repeat=n):
    B = 1
    for a, p in zip(A, P):
        B *= (a+p)
        if B%2 == 0:
            ans += 1
            break
print(ans)

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

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

b = [[] for _ in range(n)]
for i in range(n):
    b[i] = [i for i in range(max(0,a[i]-1),a[i]+2)]


def dfs(i,v,n,b):
    if i==n:
        if v==0:
            return 1
        else:
            return 0
    else:
        res = 0
        for j in b[i]:
            res += dfs(i+1,v*(j%2),n,b)

        return res
    

ans = dfs(0,1,n,b)
print(ans)

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

b = [[] for _ in range(n)]
for i in range(n):
    b[i] = [i for i in range(max(0,a[i]-1),a[i]+2)]


def dfs(i,v,n):
    if i==n:
        if v==0:
            return 1
        else:
            return 0
    else:
        res = 0
        for j in b[i]:
            res += dfs(i+1,v*(j%2),n)

        return res
    
    
ans = 0
ans = dfs(0,1,n)
print(ans)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A = list(mi())
    cnt = 0
    
    p = [1]*N
    for j in range(N-1):
        p[j+1] = 3*p[j]

    for i in range(3**N):
        B = [0]*N
        flg = False
        for j in range(N):
            t = (i//p[j])%3
            if t == 0:
                B[j] = A[j]
            if t == 1:
                B[j] = A[j]+1
            if t == 2:
                B[j] = A[j]-1

            if B[j]%2 == 0:
                flg = True
        
        if flg:
            cnt += 1

    print(cnt)

        

if __name__ == '__main__':
    main()

Solution (Python):

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

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

ans = tot_cnt - all_odd
print(ans)

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
t = 1
for i in a:
    if i&1==0:
        t*=2
print(3**n-t)

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

data = l()

od = 0
ev = 0

for i in range(n):
    if data[i] % 2 == 0:
        ev += 1
    else:
        od += 1

if od == 0:
    od = 1

print(pow(3,n) - pow(2,ev))

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = 1
for x in a:
  if x % 2 == 0: res *= 2
print(pow(3, N) - res)

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
print(3**N - odd)

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

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 = [int(e) for e in input().split()]





odd_pattern = 1

for i in range(N):
    if A_list[i]%2 == 0:
        odd_pattern *= 2
        
print(3**N - odd_pattern)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

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

Solution (Python):
def main():
	n = int(input())
	arr =list(map(int , input().split()))
	ans = 0
	allseq = 1
	bad = 1
	
	
	for i in range(0 , n):
		if arr[i]%2==0:
			bad = bad*2
		else:
			bad = bad*1
		allseq = allseq*3
	print(allseq-bad)
if __name__=="__main__":
	main()

Solution (Python):
N =int(input())
AAA = map(int,input().split())
AA = list(AAA)
total = 3**len(AA)
total2 = 0
total3 = 0
for i in AA:
  if i%2==0:
    total2 +=1
total3 = 2**total2
ans = total - total3
print(ans)

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

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

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

odd = 1

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

print(3**N - odd)

Solution (Python):
n = int(input())
ll = list(map(int, input().split()))
ans = 3**n
odd = 1
for l in ll:
  if l % 2 == 1:
    pass
  elif l % 2 == 0:
    odd *= 2

print(ans - odd)

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

ans = 0
for x in product([-1, 0, 1], repeat=n):
    b = [ai + xi for ai, xi in zip(a, x)]
    if any(bi % 2 == 0 for bi in b):
        ans += 1

print(ans)

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

Solution (Python):
import itertools
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in itertools.product((-1,0,1), repeat=N):
    for j in range(N):
        if (A[j]+i[j])%2==0:
            ans += 1
            break
print(ans)

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

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

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

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

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

cnt = 1

for i in lis:
    if i % 2 == 0:
        cnt *= 2

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

Solution (Python):
from itertools import product
N = int(input())
A = list(map(int, input().split()))
r = 0
for pp in product((-1, 0, 1), repeat=N):
    s = 1
    for p, a in zip(pp, A):
        s *= a+p
    if s % 2 == 0:
        r += 1
print(r)

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

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

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

cnt=1

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

Solution (Python):
ans = 0
number = set()
def exsearch(s, i, N, A):
    if i == N:
        global ans
        mul = 1
        for i in range(N):
            if s[i] == "0":
                mul *= A[i]

            elif s[i] == "1":
                    mul *= (A[i] - 1)

            elif s[i] == "2":
                    mul *= (A[i] + 1)

        if mul % 2 == 0:
            ans += 1

    else:
        for c in ["0", "1", "2"]:
            exsearch(s + c, i + 1, N, A)

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

    exsearch("", 0, N, A)

    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
even = 0
odd = 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
num=1
for i in range(n):
    if a[i]%2==0:
        num*=2
ans-=num
print(ans)

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

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

from itertools import product

pattern= list(product([0,1,2],repeat=n))

cnt=0
for p in pattern:
    ans=1
    for i in range(n):
        if p[i]==0:
            ans*=(a[i]-1) 
        elif p[i]==1:
            ans*=a[i] 
        else:
            ans*=(a[i]+1) 
        
    if ans%2==0:
        cnt+=1

print(cnt)

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

Solution (Python):
import numpy as np
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 = list(map(int,input().split()))
n_list = [[] for i in range(n)]
k_list = [[] for j in range(n)]

for i in range(n):
    if a[i] == 0:
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]+1)
        if (a[i]+1)%2 == 1:
            k_list[i].append(a[i]+1)
    elif a[i] == 9:
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]-1)
        if (a[i]-1)%2 == 1:
            k_list[i].append(a[i]-1)
    else:
        n_list[i].append(a[i]-1)
        if (a[i]-1)%2 == 1:
            k_list[i].append(a[i]-1)
        n_list[i].append(a[i])
        if a[i]%2 == 1:
            k_list[i].append(a[i])
        n_list[i].append(a[i]+1)
        if (a[i]+1)%2 == 1:
            k_list[i].append(a[i]+1)

ans = 0
k_s = 1
n_s = 1
for i in range(n):
    n_s = n_s*len(n_list[i])
    k_s = k_s*len(k_list[i])

print(n_s-k_s)

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

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

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

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

total = 3 ** n
odd = 1

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

print(total - odd)

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

even =[]
even_pro = 1

for a in A:
    if a % 2 == 0:
        even.append(2)
    else:
        even.append(1)

for e in even:
    even_pro *= e

print(3**n - even_pro)

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

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

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

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

import numpy as np
N = ri()
A = np.array(ri_())

print(3 ** N - np.prod(np.where(A % 2 == 0, 2, 1)))

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

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

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

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

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

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

mul = 3**n 

odd_mul = 1 

for v in a:
    if v%2 == 0:
        odd_mul *= 2
print(mul-odd_mul)

Solution (Python):
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]
ans = [1 if a&1 else 2 for a in A]
print(3**N - reduce(lambda x,y: x*y, ans))

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

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

Solution (Python):

n,*a=map(int,open(0).read().split())
e = sum(i%2 < 1 for i in a) 
print(3**n - 2**e)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    ans=pow(3,N)
    cnt=1
    for i in range(N):
        if A[i]%2==0:
            cnt*=2
            
    print(ans-cnt)

main()

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

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

Solution (Python):
n = int(input())
la = [int(w) for w in input().split()]

odd_pat = 1
max_pat = 3**n

for a in la:
    if a % 2 == 0:
        odd_pat *= 2


print(max_pat-odd_pat)

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

Solution (Python):

N = int(input())

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

ans = 3**N

d = 1
for i in range(N):

    if A[i] % 2 == 1:
        d *= 1
    else:
        d *= 2

print (ans - d)

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

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

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

amax = []
amin = []

for i in range(n):
    amax.append(a[i] + 1)
    amin.append(a[i] - 1)

m = 3 ** n

for z in range(3 ** n):
    asearch = []
    amulti = 1
    x = z
    for i in range(n):
        asearch.append(x % 3)
        x = x // 3
    for i in range(n):
        if asearch[i] == 0:
            amulti *= a[i]
        elif asearch[i] == 1:
            amulti *= amax[i]
        else:
            amulti *= amin[i]
    if amulti % 2 != 0:
        m -= 1

print(m)

Solution (Python):
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

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

for i in a:
    if i % 2 == 0:
        b *= 2

print(3**n - b)

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

O, E = [], []

for i, a in enumerate(A):
    if a % 2 == 0:
        o, e = 2, 1
    else:
        o, e = 1, 2
        
    if i == 0:
        O.append(o)
        E.append(e)
    else:           
        numo, nume = 0, 0
        numo += O[-1] * o
        nume += E[-1] * e
        nume += E[-1] * o
        nume += O[-1] * e

        O.append(numo)
        E.append(nume)

print(E[-1])

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

for x in A:
	c *= 1 if x%2 else 2
print(3**N-c)

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

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

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

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

print(3**N-even)

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

T=0
for a in A:
    T+=(a%2==0)
    
print(3**N-2**T)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=3**n
cons=1
lis=LI()
for i in range(n):
    if lis[i]%2==0:
        cons*=2
print(ans-cons)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
even_cnt = []
for i in range(n):
    if a[i]%2==0:
        even_cnt.append(1)
        a[i] = 2
    else:
        even_cnt.append(2)
        a[i] = 1
x = 3 ** n
ans = 0
for i in range(n):
    x //= 3
    ans += even_cnt[i]*x
    x *= a[i]
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
print(3**N-2**cnt)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    ca = 3 ** N
    co = 1
    for x in A:
        if x % 2 == 0:
            co *= 2
        else:
            co *= 1
    return ca - co


print(solve())

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
if N != 1:
    print(3**N-ans)
else:
    if a[0] % 2 == 0:
        print(1)
    else:
        print(2)