import Data.Char
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as B

readInt = B.readInt . B.dropWhile isSpace

getInt = fst . fromJust . readInt <$> B.getLine

getIntList = unfoldr readInt <$> B.getLine

main = do
  n <- getInt
  ds <- map (\s -> (head s, length s)) . group . sort <$> getIntList
  if fst (head ds) /= 0
    then print 0
    else print . product' . zipWith f ds $ tail ds

modInt = 998244353
product' = foldr (((`mod` modInt) .) . (*)) 1
f (a, b) (c, d)
  | c - a /= 1 = 0
  | otherwise = (b^d) `mod` modInt
