import Data.List

main :: IO()
main = do
  xs <- (reverse.sort) <$> subsequences <$> reverse.sort <$> map (read :: String -> Int) <$> tail <$> lines <$> getContents
--  xs <- show <$> maximum <$> map (reduce.sum) <$> 
  putStrLn $ show $ foldl f 0 xs

f :: Int -> [Int] -> Int
f 0 l = (reduce.sum) l
f x _ = x

reduce :: Int -> Int
reduce x
  | x `mod` 10 == 0 = 0
  | otherwise = x
