Hirky
A hill is defined as a sequence of two or more numbers that is non-decreasing. The height of a hill is the largest number in that sequence.
A hilly partition of a sequence is a collection of the fewest possible hills that, when arranged consecutively from left to right, reconstruct the original sequence.
You are given a set of numbers. Your task is to arrange these numbers into a sequence such that the sum of the heights of the hills in its hilly partition is maximized.
Input
The first line of the input contains a single integer n, representing the number of numbers in the set (2 ≤ n ≤ 100000). The second line contains n integers, each ranging from 1 to 100000, separated by spaces.
Output
The output should be a single number, representing the maximum possible sum of the heights of the hills in the sequence.