import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
total = []
for v in itertools.permutations(l):
    print(v)
    nl = list(v)
    t = 0
    for num in range(len(nl)):
        if(num != 4 and nl[num] % 10 != 0):
            print(int(nl[num] / 10) * 10 + 10)
            t += int(nl[num] / 10) * 10 + 10
        else:
            print(nl[num])
            t += nl[num]
    t = int(t)
    print(t)
    total.append(t)
print(total)
print(min(total))