let flip f x y = f y x
                   
let rec read f n =
  if n <= 0 then []
  else
    let x = f () in
    x :: read f (n - 1)

let () =
  let n = read_int () in
  let ls = read read_int n in
  let tbl = Hashtbl.create 10000 in
  let rec point ac = function
      [] -> Hashtbl.replace tbl ac true
    | h :: l -> begin
        point (ac + h) l;
        point ac l
      end
  in
  let rec find = function
      [] -> 0
    | h :: l -> if h mod 10 = 0 then find l else h in
  point 0 ls;
  Hashtbl.fold (fun p _ xs ->
                p::xs
               ) tbl [] |> List.sort (flip compare) |> find |> string_of_int |> print_endline
