Or:

Formula: copy to clipboard
=IF(A1<>A2,SUMPRODUCT(--($A$2:$A$10000=A2),($B$2:$B$10000)),"")