let () =
  let rec read l = function
      0 -> l
    | i -> read (read_int ()::l) (i-1)
  in
  let l = read [] 4
          |> List.sort compare
          |> List.rev
          |> Array.of_list and
      h = read_int () and
      g = read_int () in
  let score1 = l.(0)+l.(1)+l.(2) and
      score2 = if h > g then h else g in
  Printf.printf "%d\n" (score1+score2)
;;