from decimal import Decimal, ROUND_HALF_UP

# input
cook_time = []
append = cook_time.append

for i in range(5):
    append(int(input()))

# check
cook_time.sort(key=lambda x: int(Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_HALF_UP)) - x)
res = 0
for c in cook_time:

    if res % 10 != 0:
        res = int(Decimal(res).quantize(Decimal("1E1"), rounding=ROUND_HALF_UP))

    print(c, res)

    res += c

print(res)