See if this works on the whole sheet as it seems to work with the data you gave. ARRAY ENTERED:
I am attaching the worksheet where you will find this formula in Col I.=SUM(($B$2:$B$17=$E2)*$C$2:$C$17*(ROW($A$2:$A$17)=(MATCH($A$2:$A$17&$B$2:$B$17,$A$2:$A$17&$B$2:$B$17,0)+1)))