fun main(args: Array) { val n = readLine()!!.toInt() val ans = (1..n).map { convDec(readLine()!!) }.minOrNull()!! println(ans) } fun convDec(n:String):Long { val alpha = n.filter { it in 'A'..'Z' } var base = 10 if(alpha.isEmpty()) { base = n.map { it.toString().toInt() }.maxOrNull()!! + 1 } else { base = alpha.maxOrNull()!! - 'A' + 11 } var mul = 1L var ans = 0L for(i in n.reversed()) { if(i in '0'..'9') { ans += (i-'0')*mul } else { ans += (i-'A'+10)*mul } mul*=base } return ans }