fun main() { val n = readLine()!!.toInt() val a = readLine()!!.split(" ").map { it.toLong() } val mod = 998244353L val fact = LongArray(500000) { 1L } for (i in 1 until fact.size) { fact[i] = fact[i - 1] * i % mod } val factInv = LongArray(fact.size) { i -> if (i == fact.lastIndex) fact.last().modPow(mod - 2, mod) else 0L } for (i in fact.lastIndex - 1 downTo 0) { factInv[i] = factInv[i + 1] * (i + 1) % mod } fun combi(a: Int, b: Int): Long { return if (b in 0..a) { fact[a] * factInv[b] % mod * factInv[a - b] % mod } else { 0L } } fun cat(i: Int, j: Int): Long { return (combi(i + j + 1, j) - 2 * combi(i + j, j - 1) + mod) % mod } var ans = 0L a.reversed().forEachIndexed { i, ai -> ans = (ans + ai.toLong() * cat(n - 1, i) % mod) % mod } println(ans) } private fun Long.modPow(exponent: Long, modulus: Long): Long { var result = 1L var exp = exponent var base = this % modulus while (exp > 0) { if (exp and 1 == 1L) { result = result * base % modulus } base = base * base % modulus exp = exp shr 1 } return result }