Buggy python submission (verdict: Runtime Error):
BIGMOD = 998244353

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD

def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans

import collections

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

S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.ounter(D)
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

Fixed submission:
BIGMOD = 998244353
 
def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD
 
def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact
 
def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact
 
def modPlus(a,b):
    return (a + b) % BIGMOD
 
def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD
 
# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD
 
def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD
 
def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans
 
import collections
 
N = int(input())
D = list(map(int,input().split()))
 
S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.Counter(D)
if c[0] > 1:
  ans=0
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
BIGMOD = 998244353

def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD

def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact

def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact

def modPlus(a,b):
    return (a + b) % BIGMOD

def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD

# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD

def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD

def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans

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

S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
for i in S:
    if i == 1:
        before = D.count(i)
        before_i = i
        continue
    ans = ans*modPow(before,D.count(i))%BIGMOD
    before = D.count(i)
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)

Fixed submission:
BIGMOD = 998244353
 
def modPow(x,n):
    ans = 1
    while n >= 1:
        if bin( n & 1)==bin(1):
            ans = (ans*x) % BIGMOD
        x = x * x % BIGMOD
        n = n>>1
    return ans % BIGMOD
 
def modFact(N):
    fact = []
    fact.append(1) #0! = 1
    for i in range(1,N+1):
        a = fact[i-1]*i % BIGMOD
        fact.append(a)
    return fact
 
def modInvFact(fact):
    invFact = []
    for i in range(1,N+2):
        a = modPow(fact[i-1],BIGMOD-2)
        invFact.append(a)
    return invFact
 
def modPlus(a,b):
    return (a + b) % BIGMOD
 
def modMinus(a,b):
    if a-b >= 0:
        return (a - b) % BIGMOD
    else:
        return (a - b + BIGMOD)
    
def modMulti(a,b):
    return a * b % BIGMOD
 
# fact(n),invFact(r),invFact(n-r)
def nCr(fact,invFact,n,r):
    return (fact[n] * invFact[r] * invFact[n-r] ) %BIGMOD
 
def nPr(fact,invFact,n,r):
    return(fact[n] * invFact[r])%BIGMOD
 
def fact(num):
    ans = 1
    for i in range(1,num+1):
        ans = ans*i%BIGMOD
    return ans
 
import collections
 
N = int(input())
D = list(map(int,input().split()))
 
S = list(set(D))
S.sort()
if S[0]==0:
    S.pop(0)
ans = 1
before = 0
before_i = 0
c = collections.Counter(D)
if c[0] > 1:
  ans=0
for i in S:
    if i == 1:
        before = c[i]
        before_i = i
        continue
    ans = ans*modPow(before,c[i])%BIGMOD
    before = c[i]
    if i - before_i!=1:
        ans = 0
    before_i = i
if D[0] >0:
    print(0)
else:
    print(ans)