Natives
InterviewTime limit1sMemory limit512 MB
Given n treasure values, find the largest total the captain can keep after giving at least half of the treasures to the chieftain.
Problem
Captain Cook and his team were captured by island natives. To avoid being eaten, the adventurers must give some of their treasures to the natives. The captain has treasures.
The chieftain agrees to let the captain and his team go if they give him at least half of the treasures. The chieftain does not care which treasures he gets, as long as he receives at least half of them.
Each treasure has its own value, known to Cook. The value of the -th treasure is . Help the captain decide which treasures to give to the chieftain so that the total value of the treasures he keeps is as large as possible.
Input
The first line contains an integer ().
The second line contains integers ().
Output
Print one integer: the maximum total value of the treasures that the captain can keep after giving at least half of his treasures to the natives.