Unless there is more structure to your data and we know where the 0 indexes are I don’t see a way without using a sequential for loop.
assuming this degenerate case:
[0, 1, 0, 2, 3, 0, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 0]
IIRC expected is [0, 1, 0, 5, 0, 22, 0, 92, 0] and an additional list of list of indexes [[0], [1], [2], [3, 4], [5], [6, 7, 8, 9], ....]
If you want to generate those in a single pass without temporaries, a for loop is best.