let rec f lst maxN others = 
	match lst with
    | [] -> (maxN, others)
    | x :: xs -> 
    if x mod 10 > maxN mod 10 then f xs x (maxN :: others)
    else f xs maxN (x :: others)
let rec g maxN others = 
	match others with
    | [] -> maxN
    | x :: xs -> 
    if x mod 10 = 0 then x + g maxN xs
    else 
    let t = 10 - (x mod 10) in
    x + t + g maxN xs
let () =
	Scanf.scanf "%d\n%d\n%d\n%d\n%d\n"
    (fun a b c d e -> f ([a; b; c; d; e])) 
    |> (fun (maxN, others) -> g maxN others)
    |> print_int