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 <- map (\s -> (head s, length s)) . group . sort <$> getIntList
  let len = length ds
  let es = V.toList . V.accum (+) (V.replicate len 0) $ ds
  print . solve $ es
  
modInt = 998244353
solve [n] = n
solve (n:m:ms) = if n == 0 then 0 else ((n^m) `mod` modInt) * solve (m:ms) `mod` modInt
