L = [int(input()) for i in range(5)]
LL = [i % 10 for i in L]
if LL == [0] * 5:
    print(sum(L))
else:
    L2 = LL[:]
    while 0 in L2:
        L2.remove(0)
    ma = min(L2)
    r = LL.index(ma)
    print(ma)
    print(L[r] + sum([L[i] if L[i] % 10 == 0 else L[i] + 10 - L[i] % 10 for i in [j for j in range(5) if j != r]]))
