a=sorted(list(map(int,[input()for i in range(5)])),key=lambda x:x%10)
if ''.join([str(i)[-1]for i in a])=='00000':print(sum(a));quit()
while str(a[0])[-1]=='0':
  a+=[a[0]]
  del a[0]
print(a)
print(sum([a[0]]+[10*(0--i//10)for i in a[1:]]))