Enter this in D2 and fill across and down:
Formula: copy to clipboard
=IF($A2=$A3,"",SUMIF($A$2:$A$100,$A2,B$2:B$100))