The image above shows numbers in column B, some of these numbers are duplicates. The formula in D12 adds unique distinct numbers meaning the first instance of each number is added to the total, however, the duplicates are ignored.
Explaining formula in cell D12
If you want to examine the formula yourself then go to tab "Formula" on the ribbon and then click "Evaluate Formula" button.
This will show the calculation steps, one at a time. Simply click the Evaluate button to move to next calculation step.
Step 1 - Count each value in cell range
The COUNTIF function counts each value in the cell range and returns an array of numbers which shows the number of instances each value has.