program abc
    integer,dimension(5) :: dishes, mod10
    integer :: estimated_time, tmp = 0

    do i=1,5
        read *, dishes(i)
    end do

    do i=1,5
        mod10(i) = 10- MOD(dishes(i), 10)
    end do

    estimated_time = SUM(dishes)

    tmp = SUM(mod10, MASK=mod10<10)
    if (tmp>0) then
        estimated_time = estimated_time + tmp
    end if

    tmp = MAXVAL(mod10, MASK=mod10<10)
    if (tmp>0) then
        estimated_time = estimated_time - tmp
    end if

    print '(I0)', estimated_time
end program abc