Scanf.scanf "%d" (fun n ->
    let s = Array.init n (fun _ -> Scanf.scanf " %d" (fun s -> s)) in
    Array.sort compare s;
    let sum = Array.fold_left (+) 0 s in
    Printf.printf "%d\n" @@
        if sum mod 10 > 0 then sum else
            let rec loop i =
                if i = n then 0 else
                    if s.(i) mod 10 = 0 then loop (i + 1)
                    else sum - s.(i)
            in
            loop 0
)