module IntSet = Set.Make (struct type t = int let compare = compare end)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  Array.init n (fun _ -> Scanf.scanf "%d\n" (fun s -> s))
  |> Array.fold_left (fun set s ->
      IntSet.fold (fun s' set ->
        IntSet.add (s + s') set) set set) (IntSet.singleton 0)
  |> IntSet.elements
  |> List.filter (function 0 -> true | s -> s mod 10 <> 0)
  |> List.rev
  |> List.hd
  |> Printf.printf "%d\n"
