import Data.List

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

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