import Control.Monad
import Control.Applicative
import Data.List


main :: IO()
main = do
  lst <- replicateM 5 readLn :: IO [Int]
  let list = (reverse . sortOn fst . map (\x -> ((10 - x `mod` 10) `mod` 10, x))) lst
  let (x:xs) = list
  print (snd x + (foldl (\acc -> \(a, b) -> acc + a + b) 0 xs))
