Omkar and Circle

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!


You are given n nonnegative integers a1,a2,…,an arranged in a circle, where n must be odd (ie. n−1 is divisible by 2). Formally, for all i such that 2≤i≤n, the elements ai−1 and ai are considered to be adjacent, and an and a1 are also considered to be adjacent. In one operation, you pick a number on the circle, replace it with the sum of the two elements adjacent to it, and then delete the two adjacent elements from the circle. This is repeated until only one number remains in the circle, which we call the circular value.


Help Danny find the maximum possible circular value after some sequences of operations.


Input


The first line contains one odd integer n (1≤n<2⋅10^5, n is odd)  — the initial size of the circle.


The second line contains n integers a1,a2,…,an (0≤ai≤10^9)  — the initial numbers in the circle.


Output

Output the maximum possible circular value after applying some sequence of operations to the given circle.

SampleInput 1
3
7 10 2
SampleOutput 1
17
SampleInput 2
1
4
SampleOutput 2
4
Note
For the first test case, here's how a circular value of 17 is obtained: Pick the number at index 3. The sum of adjacent elements equals 17. Delete 7 and 10 from the circle and replace 2 with 17. Note that the answer may not fit in a 32-bit integer.

Submit
题目统计信息详细
总AC数3
通过人数3
尝试人数3
总提交量6
AC率50.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: