The president of LanXiang buys N packets of sweets for his students.However, the number of sweets in each packet is not same. For the sake of fairness, the president decides to move some sweets between the packet to make them all equal.
As he has two hands, he must always carry exactly two sweets: one in each hand. Thus, he can only make one type of an action: pick up two sweets from one of the packets and carry both of them to some other packets. Of course,he is not allowed to remove a packet completely. Therefore, he cannot pick up sweets from a packet that currently contains fewer than 3 sweets.
Now, the president want to know the minimum number of actions he has to perform in order to make all packets equal.