
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    nums <- sequence $ replicate n (readLn :: IO Int)
    putStrLn $ show $ solve $ sortBy (\a b -> compare b a) nums

solve :: [Int] -> Int
solve nums = solveImpl nums 0

solveImpl :: [Int] -> Int -> Int
solveImpl [] a = if a `mod` 10 == 0 then 0 else a
solveImpl (n:ns) a = max (solveImpl ns (n+a)) (solveImpl ns a)