Hills#326

Hills

2 seconds
64 megabytes
Medium

A hill is a non-decreasing sequence of two or more numbers. The height of a hill is defined as the largest element in this sequence.

A hilly partition of a sequence is a set of hills, using the minimal number possible, such that writing them in order from left to right reconstructs the original sequence.

You are given a set of numbers. 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 contains a single integer — the number of numbers in the set (2 \leq n \leq 100000).

The second line contains integers, each between and , separated by spaces.

Output

Print a single number: the maximum possible sum of the heights of the hills for the sequence.

Examples

Example 1

Loading
Loading