fun main() { val n = readLine()!!.toInt() val a = readLine()!!.split(" ").map { it.toLong() } if (a.any { it >= 4 }) { println(1_000_000_007) 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) }