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