fun mPow(n: Long, ex: Long, m: Long): Long {
    var x = n
    var remain = ex
    var result = 1L
    while (remain > 0) {
        if (remain % 2L == 1L) {
            result = (result * x) % m
        }
        x = (x * x) % m
        remain /= 2
    }
    return result
}

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val d = readLine()?.split(" ")?.map(String::toInt) ?: return
    val m = 998244353L
    if (d.first() != 0) {
        println("0")
        return
    }
    var count = 1L
    val map = d.groupBy { it }
    val max = d.max() ?: return
    if (map[0]?.size ?: 0 > 1) {
        println("0")
        return
    }
    1.until(max + 1).forEach { i ->
        val p = map[i - 1]?.size ?: 0
        val c = map[i]?.size ?: 0
        count = (count * mPow(p.toLong(), c.toLong(), m)) % m
    }
    println(count.toString())
}