import Data.List
f l k = if null l then 0 else if k==0 then (head l)+(f (tail l) (if mod (head l) 10 > 0 then 1 else 0)) else (head l)-(mod(head l)10)+10+f (tail l)1
main=do
 l<-sortBy (\a b->compare (mod a 10) (mod b 10)).map read.lines<$>getContents :: IO[Int]
 print$f l 0