A=[]
B=[]
C=[]
total=0
for i in range(5):
    A.append(int(input()))
for i in range(5):
    B.append(10-((A[i]%10)%10))
    C.append(((A[i]//10)+1)*10)
    total+=C[i]
B=sorted(B,reverse=True)
print(B)
print(total-B[0])