Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

F. Buy One, Get One Free

time limit per test

5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputA nearby pie shop is having a special sale. For each pie you pay full price for, you may select one pie of a strictly lesser value to get for free. Given the prices of all the pies you wish to acquire, determine the minimum total amount you must pay for all of the pies.

Input

Input will begin with an integer *n* (1 ≤ *n* ≤ 500000), the number of pies you wish to acquire. Following this is a line with *n* integers, each indicating the cost of a pie. All costs are positive integers not exceeding 10^{9}.

Output

Print the minimum cost to acquire all the pies.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

6

3 4 5 3 4 5

Output

14

Input

5

5 5 5 5 5

Output

25

Input

4

309999 6000 2080 2080

Output

314159

Note

In the first test case you can pay for a pie with cost 5 and get a pie with cost 4 for free, then pay for a pie with cost 5 and get a pie with cost 3 for free, then pay for a pie with cost 4 and get a pie with cost 3 for free.

In the second test case you have to pay full price for every pie.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/20/2018 16:12:25 (d3).

Desktop version, switch to mobile version.

User lists

Name |
---|