fun main(args: Array<String>) {
    val a = readLine()?.toInt() ?: return
    val b = readLine()?.toInt() ?: return
    val c = readLine()?.toInt() ?: return
    val d = readLine()?.toInt() ?: return
    val e = readLine()?.toInt() ?: return

    val wait = listOf(a, b, c, d, e).sortedBy {
        -((it % 10 - 10) % 10)
    }.reduce { acc, i ->
        acc - ((acc % 10 - 10) % 10) + i
    }

    println(wait.toString())
}