import Data.List
import Data.Maybe

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

solve :: [Int] -> Int
solve ss
    | t `rem` 10 /= 0 = t
    | otherwise = (maybe 0 (t -) $ find ((/=0) . (`rem` 10)) ss')
    where
        ss' = sort ss
        t = sum ss
