Score : $700$ points
You have an integer sequence of length $N$: $a_1, a_2, ..., a_N$.
You repeatedly perform the following operation until the length of the sequence becomes $1$:
You would like to maximize the final element that remains in the sequence.
Find the maximum possible value of the final element, and the way to achieve it.
Input is given from Standard Input in the following format:
$N$ $a_1$ $a_2$ $...$ $a_N$
5 1 4 3 7 5
11 3 1 4 2
The sequence would change as follows:
4 100 100 -1 100
200 2 3 1
6 -1 -2 -3 1 2 3
4 3 2 1 2
9 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
5000000000 4 2 2 2 2