import sequtils
import strutils
import algorithm

let input_list: seq[int] = map(readAll(stdin).splitLines[0..^2], parseInt)


proc cmp_totaltime(x: int, y: int): int =
    return cmp(x + (10-x.mod(10)), y + (10-y.mod(10)))

var totaltime: int = 0
var deltamax: int = -1
var deltamax_time: int = -1
var order: seq[int] = @[]

for item in input_list:
    var deltanow: int = 0
    if item.mod(10) != 0:
        deltanow = 10 - item.mod(10)

    let timenow = item + deltanow

    echo item, " ", deltanow, " ", timenow

    if deltamax == -1:
        deltamax = deltanow
        deltamax_time = item
    else:
        if deltanow > deltamax:
            totaltime += deltamax_time + deltamax
            deltamax = deltanow
            deltamax_time = item
        else:
            totaltime += timenow

echo totaltime + deltamax_time