import Data.List

g :: [Int] -> Mint
g c = product $ zipWith (^) (map M c) (tail c)

f :: [Int] -> [Int]
f d = map (pred.length) $ group $ sort $ [0..maximum d] ++ d

main :: IO ()
main = getLine >> getLine >>= print.g.f.map read.words

modulus = 998244353
newtype Mint = M Int
instance Num Mint where
  (M a) + (M b)
    | a + b < modulus = M $ a + b
    | otherwise = M $ a + b - modulus
  (M a) - (M b)
    | a - b < 0 = M $ modulus + a - b
    | otherwise = M $ a - b
  (M a) * (M b) = toEnum $ a * b
  fromInteger = toEnum . fromInteger
  abs = id
  signum = const $ M 1
instance Enum Mint where
  fromEnum (M a) = a
  toEnum a = M $ mod a modulus
instance Show Mint where
  show = show . fromEnum