Buggy python submission (verdict: Runtime Error):
from math import factorial as fact
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        a = 1
        for i in range( 1,len(c)):
            t = c[i]
            if a == 1:
                ans *= t
            else:
                ans *= ( a ** t )
                if t != 1:
                    ans = int( ans / fact(a) )
            a = t 
        print(ans)

Fixed submission:
from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
from math import factorial as fact
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        print(c)
        a = 1
        for i in range( 1,len(c)):
            t = c[i]
            if a == 1:
                print(ans)
                ans *= t
            else:
                print(ans)
                ans *= ( a ** t )
                if t != 1:
                    ans = int( ans / fact(a) )
            a = t 
        print(ans)

Fixed submission:
from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
from math import factorial as fact
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        print(c)
        a = 1
        for i in range( 1,len(c)):
            t = c[i]
            if a == 1:
                print(ans)
                ans *= t
            else:
                print(ans)
                ans *= ( a ** t )
                if t != 1
                    ans = int( ans / fact(a) )
            a = t 
        print(ans)

Fixed submission:
from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
from math import factorial as fact
from collections import Counter

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        a = 1
        for i in range( 1,len(c)):
            t = c[i]
            if a == 1:
                ans *= t
            else:
                ans *= int( a ** t / fact(a) )
            a = t 
        print(ans)


Fixed submission:
from math import factorial as fact
from collections import Counter
import sys

N = int( input() )
tree = list( map( int, input().split() ) )
ans = 1
if tree[0] != 0:
    print(0)
else:
    c = Counter(tree)
    if c[0] != 1:
        print(0)
    else:
        ans = 1
        a = c[0]
        for i in range( 1,len(c)):
            t = c[i]
            if t == 0:
                print(0)
                sys.exit()
            else:
                ans *= ( a**t )
                a = t
        print(ans%998244353)