module Main where

  import           Control.Monad
  import           Data.List
  import           Data.Ord
  import           Data.List.Split
  import           Data.Array.IO
  import qualified Data.Vector.Unboxed as V
  
  main :: IO ()
  main = do
    as <- replicateM 5 readLn :: IO [Int]
    let (zero, nonzero) = partition (\i -> i `mod` 10 == 0) as
        m = if null nonzero then 0 else head $ sortBy (\a b -> (a `mod` 10) `compare` (b `mod` 10)) nonzero
    if m == 0 then
        print $ sum $ map up as
      else
        print $ (sum zero) + (m + ((sum . (map up) . delete m) nonzero))
  
  up i = i + (10 - (i `mod` 10))
  