import collections

import sys



n = int(eval(input()))

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



cnt = collections.Counter(d)



if d[0]!=0:

    print((0))

    sys.exit(0)



if cnt[0]!=1:

    print((0))

    sys.exit(0)    

    

p = 1



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

    if cnt[i] == 0:

        print((0))

        sys.exit(0)  

    else:

        p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353



print(p)
import collections

import sys



n = int(eval(input()))

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



cnt = collections.Counter(d)



if d[0]!=0:

    print((0))

    sys.exit(0)



if cnt[0]!=1:

    print((0))

    sys.exit(0)    

    

p = 1



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

    p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353



print(p)
import collections
import sys

n = int(eval(input()))
d = list(map(int, input().split()))
cnt = collections.Counter(d)
if d[0] != 0:
    print((0))
    sys.exit(0)
if cnt[0] != 1:
    print((0))
    sys.exit(0)
p = 1
for i in range(1, max(d) + 1):
    if cnt[i] == 0:
        print((0))
        sys.exit(0)
    else:
        p = (p * pow(cnt[i - 1], cnt[i], 998244353)) % 998244353
print(p)

import collections
import sys

n = int(eval(input()))
d = list(map(int, input().split()))
cnt = collections.Counter(d)
if d[0] != 0:
    print((0))
    sys.exit(0)
if cnt[0] != 1:
    print((0))
    sys.exit(0)
p = 1
for i in range(1, max(d) + 1):
    p = (p * pow(cnt[i - 1], cnt[i], 998244353)) % 998244353
print(p)

-    if cnt[i] == 0: -        print((0)) -        sys.exit(0) -    else: -        p = (p * pow(cnt[i - 1], cnt[i], 998244353)) % 998244353 +    p = (p * pow(cnt[i - 1], cnt[i], 998244353)) % 998244353