Hi -

Have you tried something like:

=SUMPRODUCT(SUBTOTAL(109,OFFSET($L10,ROW($L10:$L108)-ROW(L10),,1)),--($R10:$R108=0)*($G11:$G108<>$G10:G107))

I don't have time to test this, and it may choke on the fact the G arrays might not be the same length as the R and L arrays. You might have to tweak it to be something like ($G11:$G109<>$G10:G108)