#C9900. Stacking Blocks
Stacking Blocks
Stacking Blocks
You are given a set of blocks, each with a certain height. The rule for stacking is that a block can be placed on top of another block only if its height is strictly less than the block directly below it. Therefore, the optimal strategy is to arrange the blocks in ascending order. Mathematically, if the block heights are given by (h_1, h_2, \dots, h_N), then the maximum height of the stack is (\sum_{i=1}^{N} h_i). Your task is to compute this maximum height.
Note: Even though there is a constraint on stacking order, any set of blocks can be rearranged in increasing order to achieve the maximum stack height.
inputFormat
The input is read from standard input. The first line contains an integer (N) indicating the number of blocks. The second line contains (N) space-separated integers representing the heights of the blocks.
outputFormat
Output a single integer on standard output, which is the maximum stack height obtainable under the stacking rules.## sample
5
3 4 1 2 5
15
</p>