import sys

lines = [int(input()) for i in range(5)]

time = 0
count = 0

for i,item in enumerate(lines):
	if item%10 == 0:
		time += item
		lines[i] = 0
		count += 1
		print(item)

for i in reversed(range(9)):
	print("#",i)
	for j,item in enumerate(lines):
		if item%10 == i+1:
			time += item
			lines[j] = 0
			count += 1
			if count != 5:
				time += (10 - (i+1))
			print(item,time)

print(time)

