from collections import Counter

N, *D = list(map(int, open(0).read().split()))

MOD = 998244353



ctr = Counter(D)

ans = 1

for i in range(1, max(ctr) + 1):

    ans = ans * ctr[i - 1] ** ctr[i] % MOD



if ctr[0] == 1 and D[0] == 0:

    print(ans)

else:

    print((0))



from collections import Counter



N = int(eval(input()))

X = list(map(int, input().split()))



MOD = 998244353

ctr = Counter(X)



if X[0] == 0 and ctr[0] == 1:

    ans = 1

    for i in range(1, max(X) + 1):

        ans *= pow(ctr[i - 1], ctr[i], MOD)

        ans %= MOD

    print(ans)

else:

    print((0))

from collections import Counter

N, *D = list(map(int, open(0).read().split()))
MOD = 998244353
ctr = Counter(D)
ans = 1
for i in range(1, max(ctr) + 1):
    ans = ans * ctr[i - 1] ** ctr[i] % MOD
if ctr[0] == 1 and D[0] == 0:
    print(ans)
else:
    print((0))

from collections import Counter

N = int(eval(input()))
X = list(map(int, input().split()))
MOD = 998244353
ctr = Counter(X)
if X[0] == 0 and ctr[0] == 1:
    ans = 1
    for i in range(1, max(X) + 1):
        ans *= pow(ctr[i - 1], ctr[i], MOD)
        ans %= MOD
    print(ans)
else:
    print((0))

-N, *D = list(map(int, open(0).read().split())) +N = int(eval(input())) +X = list(map(int, input().split())) -ctr = Counter(D) -ans = 1 -for i in range(1, max(ctr) + 1): -    ans = ans * ctr[i - 1] ** ctr[i] % MOD -if ctr[0] == 1 and D[0] == 0: +ctr = Counter(X) +if X[0] == 0 and ctr[0] == 1: +    ans = 1 +    for i in range(1, max(X) + 1): +        ans *= pow(ctr[i - 1], ctr[i], MOD) +        ans %= MOD