#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[220000],b[220000];
ll x[220000],y[220000];
int main(){
    ll n,k,ans=0;
    cin>>n;
    rep(i,0,n){cin>>a[i];b[n-1-i]=a[i];}
    rep(i,0,n)x[i]=(i>1?x[i-2]:0)+a[i];
    rep(i,0,n)y[i]=(i>1?y[i-2]:0)+b[i];
    


    /*
    for(int mask = 0; mask < (1 << n); mask++){
        ans=0;
        ll cnt=0;
        rep(i,0,n)if(mask&(1<<i)){ans+=a[i];cnt++;}
        if(ans==295&&cnt==13){
            ans=mask;
            bool pp=true;
            ll st=-1;
            while(ans>0){
                cout<<ans%2;
                if(st*(ans%2)==1)pp=false;
                st=ans%2;
                ans/=2;
            }
            if(pp) cout<<"ans";
            cout<<endl;
        }
    }*/
    
    
    if(n%2==0){
        for(ll i=0;i<n;i+=2){
            if(i+3<n)ans=max(ans,x[i]+x[n-1]-x[i+1]);
            else ans=max(ans,x[i]);
        }
        for(ll i=0;i<n;i+=2){
            if(i+3<n)ans=max(ans,y[i]+y[n-1]-y[i+1]);
            else ans=max(ans,y[i]);
        }
        cout<<ans;
    }
    else{
        ll mm=1e10;
        for(ll i=0;i<n;i+=2)mm=min(mm,a[i]);
        ans=max(x[n-1]-mm,x[n-2]);
        ll mm2=-1e10;
        for(ll i=0;i<n-1;i+=2)mm2=max(mm2,-a[i]+a[i+1]-a[i+2]);
        ans=max(ans,x[n-1]+mm2);

        mm=1e10;
        for(ll i=0;i<n;i+=2)mm=min(mm,b[i]);
        ans=max(y[n-1]-mm,max(ans,y[n-2]));
        mm2=-1e10;
        for(ll i=0;i<n-1;i+=2)mm2=max(mm2,-b[i]+b[i+1]-b[i+2]);
        ans=max(ans,y[n-1]+mm2);

        ll sum1,sum2;
        for(ll i=0;i<n-6;i+=2){
            sum1=x[i];
            for(ll j=i+3;j<n;j+=2){
                sum2=x[j]-x[i+1]+x[n-1]-x[j+1];
                ans=max(ans,sum1+sum2);
            }
        }
        for(ll i=0;i<n-6;i+=2){
            sum1=y[i];
            for(ll j=i+3;j<n-2;j+=2){
                sum2=y[j]-y[i+1]+y[n-1]-y[j+1];
                ans=max(ans,sum1+sum2);
            }
        }
        cout<<ans;
    }
}
