fun main() { val n = readLine()!!.toInt() val a = readLine()!!.split(" ").map { it.toLong() } if (a.any { it >= 4 }) { println(1_000_000_007) return } if (a.any { it == 0L }) { println(-1) return } var pi = 1L for (ai in a) { val k = (1..ai).fold(1) { acc, x -> (acc * x).toInt() } for (i in 0 until k) { pi *= ai if (pi > 1_000_000_007) { println(1_000_000_007) return } } } println(1_000_000_007 % pi) }