Problem:
Score : 600 points

Problem Statement

Given is an integer sequence A_1, ..., A_N of length N.

We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen.

Find the maximum possible sum of the chosen elements.

Here \lfloor x \rfloor denotes the greatest integer not greater than x.

Constraints

2 \leq N \leq 2\times 10^5

|A_i|\leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the maximum possible sum of the chosen elements.

Sample Input 1

6
1 2 3 4 5 6

Sample Output 1

12

Choosing 2, 4, and 6 makes the sum 12, which is the maximum possible value.

Sample Input 2

5
-1000 -100 -10 0 10

Sample Output 2

0

Choosing -10 and 10 makes the sum 0, which is the maximum possible value.

Sample Input 3

10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 3

5000000000

Watch out for overflow.

Sample Input 4

27
18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49

Sample Output 4

295

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
int inf=100000000;
const double PI = 3.14159265358979323846;
/*Graph t;
void dfs(int v, int pv=-1){
    for(int vn: t[v]){
        if (vn == pv) continue;
        dfs(vn, v);
    }
}*/
int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll k[n][3][2];
  rep(i,n)rep(j,3)rep(h,2)k[i][j][h]=-1000000000000000000;
  k[0][0][1]=a[0];
  k[0][1][0]=0;
  rep(i,n-1){
    int y=i+1;
    k[y][0][1]=k[i][0][0]+a[y];
    k[y][0][0]=k[i][0][1];
    k[y][1][0]=max(k[i][1][1],max(k[i][0][0],k[i][0][1]));
    k[y][1][1]=k[i][1][0]+a[y];
    k[y][2][0]=max(k[i][2][1],max(k[i][1][0],k[i][1][1]));
    k[y][2][1]=k[i][2][0]+a[y];
  }
  if(n%2==1)cout << max(max(k[n-1][0][0],k[n-1][0][1]),max(max(k[n-1][1][0],k[n-1][1][1]),max(k[n-1][2][0],k[n-1][2][1]))) << endl;
  else cout << max(max(k[n-1][0][0],k[n-1][0][1]),max(k[n-1][1][0],k[n-1][1][1])) << endl;
}