Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max(d)+1):
        dc = d.count(i)
        if dc == 0:
            print(0)
            exit()
        if dc == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dc, 998244353)
        b = dc
    print(ans % 998244353)
else:
    print(0)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max(d)+1):
        dc = d.count(i)
        if dc == 0:
            print(0)
            exit()
        if dc == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dc)
        b = dc
    print(ans % 998244353)
else:
    print(0)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
maxd = max(d)
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, maxd+1):
        dc = d.count(i)
        if dc == 0:
            print(0)
            exit()
        ans *= math.pow(b, dc)
        b = dc
    print(ans % 998244353)
else:
    print(0)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max(d)+1):
        if d.count(i) == 0:
            print(0)
            exit()
        ans *= pow(b, d.count(i))
        b = d.count(i)
    print(ans % 998244353)
else:
    print(0)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)