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



Sample input:
2
2 3


Sample output:
7

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    if N == 1:
        return print(1 if A[0] % 2 == 0 else 2)
    ans = 0
    d = (-1, 0, 1)
    from itertools import product
    for i in product(range(3), repeat=N):
        cur = 1
        for j in range(N):
            cur *= (A[j] + d[i[j]])
        if cur % 2 == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
e=sum(x%2==0 for x in a)
print(3**n-2**e)

Submission status: Accepted

Solution code:
n = int(input())
al = list(map(int,input().split()))

ans = 3 ** n
tmp = 1
for a in al:
    if a % 2 == 0:
        tmp *= 2

print(ans-tmp)

Submission status: Accepted

Solution code:
import itertools


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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
from copy import deepcopy

# 全探索でいけるやろ
n = int(input())
a = list(map(int, input().split()))
ans = 0


def f(ret, idx):
    if idx == n:
        yield ret
    else:
        for x in [-1, 0, 1]:
            next_ret = deepcopy(ret)
            next_ret.append(a[idx] + x)
            yield from f(next_ret, idx + 1)


for g in f([], 0):
    res = len(list(filter(lambda x: x % 2 == 0, g)))
    ans += 1 if res > 0 else 0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]

l = [i for i in l if i % 2 == 0]

print(3 ** n - 2 ** len(l))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
e=1
for i in A:
    if i%2==0:
        e*=2#奇数が2パターンある
    else:
        e*=1#奇数が1パターンある
print(3**N-e)#全通り ー 積が奇数の組

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    ans = 1
    for i in range(N):
        if A[i]%2==1:
            pass
        else:
            ans *= 2
        
    print(3**N-ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

show_flg=False
show_flg=True

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

Submission status: Accepted

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

al = 3 ** n
sub = 1

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

print(al - sub)

Submission status: Accepted

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

Submission status: Accepted

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

tot = 3 ** N

cnt_odd, cnt_even = 0,0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(whole-odds)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

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

print(a-point)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 3**n

temp = 1
for i in a:
    if i % 2 == 0:
        temp*=2
ans -= temp
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
List = list(map(int,input().split()))
odd = [1 for _ in range(n)]
for item in List:
  if item % 2 == 0:
    odd.append(2)
  else:
    odd.append(1)
odd_factor = 1
for item in odd:
  odd_factor *= item
Answer = 3**n -odd_factor
print(Answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


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

    return



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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    ans = 1
    t = 1
    for i in range(N):
        # if A[i] == 1 or A[i] == 100:
        #     t *= 2
        #     continue

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

    return



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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

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

dfs(0)
print(ans)

Submission status: Accepted

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

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

odd = 0
even = 0

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(3 ** N - res)

Submission status: Accepted

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

s = 3**n

t = 1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import product

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - Similar Arrays
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
N = ni()
A = nl()

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(3**n - cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import os
import sys

import numpy as np

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(3**n - cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#%%
n = int(input())
a = list(map(int, input().split()))
even = 0
for i in range(n):
    if a[i] % 2 == 0:
        even += 1

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




#%%

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from functools import reduce
from operator import mul


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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 2019/09/21

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import functools, operator

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(3 ** N - num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
odd = 1
for i in input().split():
  odd *= 1 if int(i) % 2 else 2
print(3**n - odd)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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