let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let ( *@) a b = (a * b) mod 998244353 in
    let calc a b acc =
        let rec loop k i acc =
            if i = 0 then acc else
                let acc = if i mod 2 = 1 then acc *@ k else acc in
                let k = k *@ k in
                loop k (i / 2) acc
        in
        loop a b acc
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let d = Array.of_list (split (read_line ())) in
        let r =
            if d.(0) <> 0 then 0 else (
                let hist = Array.make n 0 in
                Array.iter (fun v -> hist.(v) <- hist.(v) + 1) d;
                let dmax = Array.fold_left max 0 d in
                if hist.(0) <> 1 then 0 else (
                    let rec loop i acc =
                        if i = dmax then acc else loop (i + 1) (calc hist.(i) hist.(i + 1) acc)
                    in
                    loop 0 1
                )
            )
        in
        Printf.printf "%d\n" r
    in
    main ()