main :: IO ()
main = do
  xs <- map read . words <$> getContents
  print $ solve xs

solve :: [Int] -> Int
solve xs = go 0 0 xs
  where
    go s p [] = s - p
    go s p (x:xs) = go (s + x1) (p `max` p1) xs
      where
       r = x `mod` 10
       p1 = if r == 0 then 0 else 10 - r
       x1 = x + p1