object Main extends App{ val n = io.StdIn.readInt var p = io.StdIn.readLine.split(" ").map(_.toLong).product while(p.toString.size != 1){ p = p.toString.split("").map(_.toLong).sum } println(p) }