s = []
for i in range(5):
    s.append(int(input()))
s1 = [str(e)[-1] for e in s]
s2 = [int(e) if e != '0' else 10 for e in s1]
time_min = s2.index(min(s2))
s_min = s.pop(time_min)
s3 = [-(-e//10)*10 for e in s]
result = sum(s3) + s_min
print(s2, s_min)
print(result)