fun main(args: Array<String>){

    var N = readLine()!!.toInt()
    var D = readLine()!!.split(" ").map{it.toLong()}
    var countArray = LongArray(N){0}
    var ans :Long = 1
    val MOD = 998244353

    for(i in countArray.indices){
        countArray[D[i].toInt()]++
    }

    for(i in countArray.indices){

        for(j in 0 until countArray[i]){
            if(i != 0) ans = ans * countArray[i-1] % MOD
        }
    }

    if(D[0] != 0L){
        println(0)
    } else if(countArray[0] != 1L) {
        println(0)
    } else {
            if(ans < 0) ans += MOD
            println(ans)
        }
}
