A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = int(0.1*(5+A))
b = int(0.1*(5+B))
c = int(0.1*(5+C))
d = int(0.1*(5+D))
e = int(0.1*(5+E))
t_1 = 10*(a+b+c+d) + E
t_2 = 10*(b+c+d+e) + A
t_3 = 10*(c+d+e+a) + B
t_4 = 10*(d+e+a+b) + C
t_5 = 10*(e+a+b+a) + D
print(min([t_1,t_2,t_3,t_4,t_5]))