import Control.Monad
import Data.Array
import Data.List

sums :: Int -> Int -> Array Int Int -> [Int]
sums a d scores
  | d >= length scores = [a]
  | otherwise = sums (a + (scores ! d)) (d + 1) scores ++ sums a (d + 1) scores

solve :: Array Int Int -> Int
solve scores =
  maximum $ 0 : ((sort . filter (\x -> (x `mod` 10) /= 0)) $ sums 0 0 scores)

main :: IO ()
main = do
  n <- readLn
  scores <- replicateM n readLn
  print $ solve $ listArray (0, n - 1) scores
