Question
Circular Donation Booths
A charity fair has
Find the maximum donation that can be collected.
Input
The first line contains an integer KaTeX can only parse string typed expression — the number of booths.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the donation values.
Output
Print a single integer — the maximum donation that can be collected.
Example
Example 1:
Input
Choose booths with values KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
Example 2:
Input
The two KaTeX can only parse string typed expression booths are adjacent in the circle, so they cannot both be chosen.
Input
5
2 3 2 5 1Output8ExplanationChoose booths with values KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
Example 2:
Input
4
10 1 1 10Output11ExplanationThe two KaTeX can only parse string typed expression booths are adjacent in the circle, so they cannot both be chosen.