With GROUPBY the formula in cell D1 looks like this:
GROUPBY
=GROUPBY(B:B,A:A,SUM,3,0)
GROUPBY function reference