MCIPC Contest 2 P4 - Wreath
View as PDFFiona 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  partitions in the wreath. She then assigned the 
 partition a festive score of 
. Since the wreath is circular, the index of the next clockwise partition of 
 will be 
. She will then choose a spot to place a bow. When a bow is placed at partition 
, the left score 
 is defined as the sum of 
 festive scores counter-clockwise from the 
 partition, while the right score 
 is defined as the sum of 
 festive scores clockwise from the 
 partition. The total score is equal to 
.
Note:  and 
 can include a partition multiple times.
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  space separated integers, where the 
 integer represents the festive score of the 
 partition.
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  partition.
Sample Input 2
4
1 2 2 4
Sample Output 2
4
Comments