import Data.Char
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V

readInt = B.readInt . B.dropWhile isSpace

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

getIntList = unfoldr readInt <$> B.getLine

main = do
  n <- getInt
  ds <- group . sort <$> getIntList
  let es = go [0..] ds
  if all (/= 0) es
    then print . solve $ es
    else print 0
    where
      go _ [] = []
      go (n:ns) sss@(s:ss)
        | n == head s = length s : go ns ss
        | otherwise   = 0 : go ns sss
      solve ns = foldr (((`mod` modInt) .) . (*)) 1 . zipWith pow' ns $ tail ns

modInt = 998244353
pow' x y
  | y == 0 = 1
  | even y = ((pow' x (y `div` 2)) ^ 2) `mod` modInt
  | otherwise = x * (pow' x (y - 1)) `mod` modInt
