main=do
 s<-map read.lines<$>getContents
 let p = foldl1 (\x y -> if y`mod`10/=0&&y-read(init(show y))*10<=x-read(init(show x))*10then y else x) s
 let t = map (\x -> read(init(show x))*10+10) (filter (/=p) s)
 print$sum t + p