#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll inf=1e18;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll res=0;
    for(int i=1;i<N-1;i+=2){
        res+=a[i];
    }
    ll dp1[N+1]={};
    ll dp2[N+1]={};
    dp1[1]=a[0];
    dp2[N-1]=a[N-1];
    for(int i=2;i<=N;i++){
        dp1[i]+=dp1[i-2]+a[i-1];
    }
    for(int i=N-2;i>=0;i--){
        dp2[i]+=dp2[i+2]+a[i];
    }
    /*
    for(int i=0;i<=N;i++){
        cout << dp1[i] << " ";
    }
    cout << endl;
    for(int i=0;i<=N;i++){
        cout << dp2[i] << " ";
    }
    cout << endl;
    */
    if(N%2==0){
        cout << max(dp1[N],dp1[N-1]) << endl;
    }else{
        ll ans=-1*inf;
        for(int i=1;i<N;i++){
            ans=max(dp1[i-1]+dp2[i+1],ans);
        }
        cout << max(ans,res) << endl;
    }
}