How can I get the highest value from a subset of rows and use it for the next subset or group

I am trying to calculate a linear timeline instead of an accumulative one. I have a bunch of rows that are dependent on the previous one or ones and want to use the highest value to start the next group of calculations.

I attached a file with more explanation.

Thank you in advanced!

group-time-calculations.ods

UPDATE: The cells referenced in the notes in this file are shifted due to some formatting changes. They are shifted by 2 rows.

Please see the formulas on the second sheet’s columns C and D: times.ods.

And this setup allows to write entries in random order in rows 2 and below (like “1-2-1-1-3-2-4-7-6-5…”): times2.ods

This is exactly what I am looking for! Thank you!