Problem library

Combo Damage

Easy
arrayssimulation

In a combo, every hit deals its listed damage, except that every third hit in a row (the 3rd, 6th, 9th, ...) is a critical hit and deals double damage.

A hit of 0 is a miss: it deals nothing and resets the combo, so the count of hits in a row starts again from the next hit.

Return the total damage.

Examples

Input: hits = [5,5,5,5]
Output: 25
Input: hits = [4,4,0,4,4,4]
Output: 24