Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = ans*(count_dict[i-1]**count_dict[i])
    if ans == 0:
        break

print(ans%998244353)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

d_l.sort()
d_l = d_l[1:]
count_l = [1,]

for i in range(1,n):
    count_l.append(d_l.count(i))
    d_l = d_l[count_l[i]:]
    ans = (ans*(count_l[i-1]**count_l[i]))%998244353
    if d_l == [] or ans == 0:
        break

print(ans)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

d_l.sort()
d_l = d_l[1:]
count_l = [1,]

for i in range(1,n):
    count_l.append(d_l.count(i))
    d_l = d_l[count_l[i]:]
    ans = ans*(count_l[i-1]**count_l[i])
    if d_l == [] or ans == 0:
        break

print(ans%998244353)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

n_tmp = n-1
count_l = [1,]

for i in range(1,n):
    count_l.append(d_l.count(i))
    ans = ans*(count_l[i-1]**count_l[i])%998244353
    n_tmp -= count_l[i]
    if n_tmp == 0 or ans == 0:
        break

print(ans)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

count_l = [0] * n
for i in range(n):
    count_l[i] = d_l.count(i)

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

n_tmp = n-1
for i in range(1,n):
    ans = ans*(count_l[i-1]**count_l[i])%998244353
    n_tmp -= count_l[i]
    if n_tmp == 0:
        break

print(ans)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))

count_l = [0] * n
for i in range(n):
    count_l[i] = d_l.count(i)

if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

n_tmp = n-1
for i in range(1,n):
    ans = ans*(count_l[i-1]**count_l[i])
    n_tmp -= count_l[i]
    if n_tmp == 0:
        break

print(ans%998244353)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d_l = list(map(int,input().split()))


if d_l[0] != 0 or d_l.count(0) != 1:
    ans = 0
else:
    ans = 1

n_tmp = n-1
for i in range(1,n):
    n_tmp2 = d_l.count(i-1)
    n_tmp3 = d_l.count(i)
    ans = ans*(n_tmp2**n_tmp3)
    n_tmp -= n_tmp3
    if n_tmp == 0:
        break

print(ans%998244353)

Fixed submission:
n = int(input())
d_l = list(map(int,input().split()))

count_dict = {}
for i in range(n):
    count_dict[i] = 0
for val in d_l:
    count_dict[val] += 1

if d_l[0] != 0 or count_dict[0] != 1:
    ans = 0
else:
    ans = 1

for i in range(1,n):
    ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353
    if ans == 0:
        break

print(ans)