fun main(args: Array<String>) {
    val num = readLine()?.toInt() ?: return
    val values = (1..num).mapNotNull { readLine() }
    val mutableList = mutableListOf(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
    values.forEach { v ->
        values.filter { it != v }.forEach {
            mutableList.add("$it$v".toInt())
            mutableList.sort()
            mutableList.removeAt(3)
        }
    }
    println(mutableList.last())
}

