Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
q=[]
#from collections import Counter
#q=Counter(d)

for i in range(max(d)+1):
    q.append(d.count(i))

if q[0]!=1 or d[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(d)+1):
    ans*=q[i-1]**q[i]
    if ans == 0:
        break
print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
q=Counter(d)

if q[0]!=1 or d[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(D)+1):
    ans*=q[i-1]**q[i]
    if ans == 0:
        break
print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
q=Counter(d)

if d[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(D)+1):
    ans*=q[i-1]**q[i]
print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
q=Counter(d)

if D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(D)+1):
    ans*=q[i-1]**q[i]
print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
q=Counter(d)

if D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(D)+1):
    ans*=q[i-1]**q[i]

print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))

from collections import Counter
q=Counter(d)

if D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(1,max(D)+1):
    ans*=q[i-1]**q[i]
print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=list(map(int,input().split()))
ans=1
if D[0]!=0:
    print(0)
else:
    for i in range(max(D)-1):
        ans*=D.count(i+1)**D.count(i+2)
        if ans==0:
            break
    print(ans%998244353)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=list(map(int,input().split()))
ans=1
if D[0]!=0:
    print(0)
else:
    for i in range(max(D)-1):
        ans*=D.count(i+1)**D.count(i+2)
        ans%=998244353
    print(ans)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
 
from collections import Counter
q=Counter(d)

# 例外対応
if q[0]!=1 or d[0]!=0:
  print(0)
  exit()

ans = 1
for i in range(1,max(d)+1):
  ans *= q[i-1]**q[i]
  if ans == 0:
    break
print(ans%998244353)