Fiona is making a decorative wreath to hang outside of the math club room. She is almost done making the wreath and realized that she has forgotten to put a bow on the wreath! All good wreaths must have a bow. However, where should she place the bow?
Fiona took the wreath and identified
Note:
What is the maximum possible total score that can be achieved?
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains the integer
The second line contains
Output Specification
Output a single integer, the maximum total score possible.
Sample Input 1
5
1 3 5 3 1
Sample Output 1
7
Explanation for Sample 1
An optimal solution is to choose the
Sample Input 2
4
1 2 2 4
Sample Output 2
4
Comments