A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ans3 = 0

food = [A, B, C, D, E]

last_food = []

for i in food:
	sub = i % 10
	sub_last_food = 10 - sub
	
	if sub_last_food == 10:
		x = 0
	else:
		x = sub_last_food
		
	last_food.append(x)
	print(last_food)
	
ans = max(last_food)
print(ans)

ans1 = last_food.index(ans)
print(ans1)

for i in range(5):
	ans2 = food[i] + last_food[i]
	ans3 = ans3 + ans2
	print(ans3)

ans4 = ans3  - last_food[ans1]

print(ans4)