This gives the outcome you show from your example data:
Edit Seems to have ‘done the trick’, so some explanation:
=SUMIFS syntax is
SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...)
So in this case the formula is summing ColumnD values where in the corresponding row the ColumnB value is whatever happens to be in ColumnB for the row containing the formula and the ColumnC value is -1
.
The answer does not repeat a column for unique values of ID because only three distinct IDs are shown in the example and, conveniently, these are the first three and in order.