Are other HR values important? Do you wish to keep the data format same? Just asking because the calculation is much easier to perform from table like this

You can also try to use formulas like these
numerator:
:E[Col Min(If(:HR == 600, Row(), .), :Animal ID)]
denominator:
:"early e'"n[Col Min(If(:HR == 400, Row(), .), :Animal ID)]

-Jarmo