import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    dc=Counter(D)
    dci=list(dc.items())
    dci.sort()
    mod,ans=998244353,1
    if D[0]!=0 or (D[0]==0 and dci[0][1]>1):
        print(0)
        sys.exit()
    for i in range(len(dci)):
        if dci[i][0]!=i:
            print(0)
            break
        if i>=2:
            ans*=dci[i-1][1]**dci[i][1]%mod
    else:
        print(ans)

if __name__=='__main__':
    main()