JOI and IOI are twin siblings. JOI has been absorbed in baking lately, so he baked a cake today too. The moment it came out of the oven, IOI smelled it and came over, so the two decided to share the cake.
The cake is round. Straight cuts from one point outward split the cake into N pieces, and the pieces are numbered 1 to N counterclockwise. That is, for every i with 1≤i≤N, piece i touches piece i−1 and piece i+1, where piece 0 means piece N and piece N+1 means piece 1. Piece i has size Ai, and because the cutting was clumsy, all Ai are different.
The two split the pieces as follows.
JOI wants the total size of the pieces he takes to be as large as possible.
Given the number of pieces N and the size of each piece, write a program that finds the largest total size JOI can take.
The first line contains the number of pieces N.
Each of the next N lines contains one integer. Line i contains Ai, the size of piece i.
Print the largest total size JOI can take on one line.