a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = a+b+c+d+e
l = []
l.append((10-a%10)%10)
l.append((10-b%10)%10)
l.append((10-c%10)%10)
l.append((10-d%10)%10)
l.append((10-e%10)%10)
l.sort()
print(l)
print(s)
print(s+sum(l[:-1]))