Byteasar the hacker qualified for this year's international hacking olympiad. One of the events is a game against a system operator. There are n computers numbered 1 to n, connected in a ring: computer i is connected to computer i+1 for i=1,…,n−1, and computer n is connected to computer 1.
The rules of the game are these.
At the start no computer is hacked or protected. Computer i stores data of value vi, and Byteasar scores vi for every computer i he hacks. Compute the highest score Byteasar can reach when the operator plays optimally.
The first line contains the number of computers n. (2≤n≤50000)
The second line contains n integers v1,v2,…,vn separated by spaces, where vi is the value of the data stored on computer i. (1≤vi≤2000)
Print one integer: Byteasar's highest score against an optimally playing operator.
In the first example Byteasar hacks computer 2 and scores 6. The operator answers by protecting computer 3. Byteasar then hacks computer 1 and scores 7, and finally the operator protects computer 4.