import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  ns <- map (read::String->Int) . lines <$> getContents
  let timelist = zip ns $ map calcWaiting ns
  print $ (sum . map (uncurry (+))) timelist - (maximum . map snd) timelist

calcWaiting::Int->Int
calcWaiting x
  |mod x 10 == 0 = 0
  |otherwise     = 10 - mod x 10
