


1. If 'x' == 'y', both stones are totally destroyed;
2. If 'x' != 'y', the stone of weight 'x' is totally destroyed, and the stone of weight 'y' has a new weight equal to 'y - x'.
The first line of input contains the integer 'N', representing the total number of stones.
The second line of input contains 'N' single space-separated integers, representing the weights of the stones.
The only output line prints the weight of the last stone, if it exists, 0 otherwise.
You do not need to print anything; it has already been taken care of. Just implement the given functions.
1 <= N <= 10^5
1 <= W <= 10^6
Time Limit: 1 sec
We will store the stones in a vector/list and run a while loop until the size of the vector/list is greater than 1
We can use a max priority queue to solve this question. Store the weights of all stones in the queue and then while its size is greater than 1 do the following:
After you've completed the above process, you should have one element left in the queue. Simply return it.