(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let lst = 
        List.init 5 (
                fun _ -> 
                        Scanf.sscanf (read_line ()) "%d" (
                                fun n -> n
                        )
        )
        |> List.sort (fun el1 el2 ->
                let d1 = (10 * ((el1 / 10) + 1) - el1) mod 10 in
                let d2 = (10 * ((el2 / 10) + 1) - el2) mod 10 in
                        if d1 = d2 then
                                0
                        else
                        if d1 < d2 then
                                -1
                        else
                                1

        )

let rec f lst =
        match lst with
                  [] -> 0
                | first :: [] -> first
                | first :: rest -> 
                        let r = f rest in
                                if first mod 10 = 0 then
                                        first + r
                                else
                                        let d = (10 * ((first / 10) + 1)) in
                                                d + r

let () =
        f lst
        |> Printf.printf "%d\n"
