n=int(eval(input()))

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

maxd=max(d)

import collections

counter=collections.Counter(d)

if d[0]!=0 or counter[0]!=1:

  print((0))

else:

  a=1

  ans=1

  for i in range(1,maxd+1):

    if i not in counter:

      print((0))

      break

    else:

      b=counter[i]

      ans*=(a**b)

      a=b

  else:

    print((ans%998244353))

n=int(eval(input()))

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



if d[0]!=0:

  print((0))

  exit(0)

  

m=max(d)

counts=[0]*(m+1)



import collections

counter=collections.Counter(d)



for key,val in list(counter.items()):

  counts[key]=val

if counts[0]!=1:

  print((0))

  exit(0)

ans=1

div=998244353

for i in range(1,len(counts)):

  ans*=pow(counts[i-1],counts[i],div)

  ans%=div

  

print(ans)
n = int(eval(input()))
d = list(map(int, input().split()))
maxd = max(d)
import collections

counter = collections.Counter(d)
if d[0] != 0 or counter[0] != 1:
    print((0))
else:
    a = 1
    ans = 1
    for i in range(1, maxd + 1):
        if i not in counter:
            print((0))
            break
        else:
            b = counter[i]
            ans *= a**b
            a = b
    else:
        print((ans % 998244353))

n = int(eval(input()))
d = list(map(int, input().split()))
if d[0] != 0:
    print((0))
    exit(0)
m = max(d)
counts = [0] * (m + 1)
import collections

counter = collections.Counter(d)
for key, val in list(counter.items()):
    counts[key] = val
if counts[0] != 1:
    print((0))
    exit(0)
ans = 1
div = 998244353
for i in range(1, len(counts)):
    ans *= pow(counts[i - 1], counts[i], div)
    ans %= div
print(ans)

-maxd = max(d) +if d[0] != 0: +    print((0)) +    exit(0) +m = max(d) +counts = [0] * (m + 1) -if d[0] != 0 or counter[0] != 1: +for key, val in list(counter.items()): +    counts[key] = val +if counts[0] != 1: -else: -    a = 1 -    ans = 1 -    for i in range(1, maxd + 1): -        if i not in counter: -            print((0)) -            break -        else: -            b = counter[i] -            ans *= a**b -            a = b -    else: -        print((ans % 998244353)) +    exit(0) +ans = 1 +div = 998244353 +for i in range(1, len(counts)): +    ans *= pow(counts[i - 1], counts[i], div) +    ans %= div +print(ans)