In an experiment with molecules of several integer weights, a curious phenomenon has been detected: repeatedly, the lightest and the heaviest molecules are combined, they disappear, and generate a new molecule with the average of the two weights (rounded down if necessary). The process finishes when only one molecule exists.
For example, if the initial weights are 1, 3, 4 and 8, first of all 1 and 8 are combined and generate a molecule with weight . We now have 3, 4 and 4, and 3 and 4 are combined, generating a new molecule with weight . Now we only have 3 and 4, which are combined to generate one with weight 3, which is the final result.
Write a program that efficiently simulates this process and writes the weight of the last molecule.
The input consists of several cases. Each case begins with the number of molecules , followed by weights, which are integers between 1 and . You can assume that .
For each case, write the weight of the last molecule.
We advise you not to use multisets to solve this problem.
Input
4 1 3 4 8 2 1000000000 999999999 1 42 3 23 23 23 5 5 4 1 2 3
Output
3 999999999 42 23 3