f n = if null(init(show n)) then n else n-read(init(show n))*10
gread n = if null n then 0 else read n
g p (s:ss) = if null ss then [0] else if s==p then ss else s:(g p ss)
main=do
 s<-map read.lines<$>getContents
 let p = foldl1 (\x y -> if y`mod`10/=0 && f y<=f x then y else x) s
 let t = map (\x -> if x`mod`10/=0 then gread(init(show x))*10+10 else x) (g p s)
 print$sum t + p