let n = Scanf.scanf "%d" (fun x -> x)
let s = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
let a = Array.make 10010 false
let () =
  a.(0) <- true;
  s |> Array.iter begin fun c ->
    for i = (10010-1) downto c do
      a.(i) <- a.(i) || a.(i-c)
    done
  end;
  a |> Array.to_list |> List.mapi (fun i e -> i, e)
  |> List.filter (fun (i,e) -> i mod 10 <> 0 && e)
  |> List.fold_left (fun v (i,e) -> max v i) 0
  |> Printf.printf "%d\n"