let without ls j =
  let temp = ref [] in
  for i = 0 to (List.length ls) - 1 do
    if i <> j then temp := (List.nth ls i)::!temp
  done;
  List.rev !temp

let solve ar =
  let ls = Array.to_list ar in
  let rec inner cur_time = function
    | [] -> cur_time
    | ls ->
       let next_time = if (cur_time mod 10) <> 0 then
                         cur_time + (10 - (cur_time mod 10))
                       else cur_time
       in let min_time = ref max_int in
       for i = 0 to (List.length ls) - 1 do
         let l = List.nth ls i in
         let ls = without ls i in
         min_time := min !min_time (inner (next_time + l) ls)
       done;
       !min_time
  in inner 0 ls

let _ =
  let ar = Array.make 5 0 in
  for i = 0 to 4 do
    Scanf.scanf "%d\n" (fun a -> ar.(i) <- a)
  done;
  solve ar |> print_int
