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