#P7522. ⎌ Nurture ⎌
⎌ Nurture ⎌
Description
Mivik is listening to Nurture, but then the coach walks in, so Mivik pretends to be working on this problem.
You are given a sequence of length . Each time, you may take out two numbers , and add to the sequence. Repeat the operation until only one number remains in the sequence. You need to find the maximum possible value of this remaining number.
(As a result, the coach solved this easy problem at a glance, and Mivik was criticized for doing easy problems for no reason.)
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains integers. The -th integer represents the -th element of the sequence.
Output Format
Output one integer in one line, representing the maximum possible value of the final remaining number.
3
1 2 3
4
4
-4 5 -2 -3
14
8
2 0 2 1 0 4 2 3
14
Hint
Sample Explanation
Sample 1: In the first step, take out and add to the sequence. The sequence becomes . Then take out and add to the sequence. Now only one number remains. It can be proven that there is no sequence of operations that makes the remaining number larger.
Constraints
For all testdata, , .
Subtask 1 (15 pts): .
Subtask 2 (30 pts): .
Subtask 3 (55 pts): No additional constraints.
Input Format
Output Format
Translated by ChatGPT 5
京公网安备 11011102002149号