fun main() { val builder = StringBuilder() readInputLine() val pArr = readInputLine().split(" ").map { it.toLong() } if (pArr.contains(0L)) { builder.appendLine(0) } else { builder.appendLine(pArr.fold(1L) { acc, l -> root(acc * (l % 9L)) }) } print(builder.toString()) } fun readInputLine(): String { return readLine()!! } fun root(a: Long): Long { return if (a % 9L != 0L) a % 9L else 9L }