import Data.List

main = print . solve . map read . drop 1 . words =<< getContents

solve :: [Int] -> Int
solve xs
    | total `mod` 10 /= 0 = total
    | target == [] = 0
    | otherwise = total - minimum target
    where
        total = sum xs
        target = filter (\x -> x `mod` 10 /= 0) xs
