I would probably go for:

D3: =IF(D2=0,0,LOOKUP(10^10,CHOOSE({1,2},0,SMALL($A$3:$B$28,1+COUNTIF($A$3:$B$28,"<="&N($D2))))))
copied down
Custom Format applied to D3:Dx of: [=0]"";h:mm:ss

E3:
=IF(N($D3),COUNTIF($A$3:$B$28,$D3),"")
copied down

(Note some of your times are unique based on seconds)