This solution makes use of two helper columns*, D and E, with the respective formulas:
=IF(B2=0,"",ROW())
=IF(B2=0,"",IFERROR(LARGE(INDIRECT(ADDRESS(ROW()-1,4)&":D1"),1),1))
The formula in column C is:
=IF(B2=0,"",D2-E2)
*Helper columns can be hidden for aesthetic purposes.
Here is a copy of your file with the helper columns and formulas applied: Copy of example IFERROR(LARGE(INDEX(ADDRESS....xlsx
Let me know if you have any questions.