class Solution {
public:
int arrayPairSum(vector<int>& nums) {
int sum = 0;
std::sort(nums.begin(), nums.end());
for (int i = 0; i < nums.size() - 1; i += 2)
sum += nums[i];
return sum;
}
};

@gabbu Hi, thanks for your answer.
Just have one question about
Now note that 1 needs to be a paired with a larger number. What is the number we would like to sacrifice? Clearly the smallest possible.

Why the 'smallest'? We have no chance to remove the smallest number but largest