import numpy as np

nums = []
sortedNums = [0,0,0,0,0]
sortedRemainders = [0,0,0,0,0]
for i in range(5):
	nums.append(int(input()))

remainders = [0,0,0,0,0]
for i in range(5):
	remainders[i] = nums[i] % 10

sortedRemaindersIndex = np.ndarray.tolist(np.argsort(remainders))

for i in range(5):
	sortedRemainders[i] = remainders[sortedRemaindersIndex[i]]
	sortedNums[i] = nums[sortedRemaindersIndex[i]]

print(sortedRemainders)
print(sortedNums)

elapsedTime = 0
lastIndex = 0
foundLastIndex = False
for i in range(5):
	if sortedRemainders[i] == 0:
		elapsedTime += sortedNums[i]
	else:
		if foundLastIndex:
			elapsedTime += sortedNums[i] + 10 - sortedRemainders[i]
		else:
			lastIndex = i
			foundLastIndex = True
	print(elapsedTime)

elapsedTime += sortedNums[lastIndex]

print(elapsedTime)