//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  if(n%2==0){
    ll p=0,q=0;
    rep(i,n){
      if(i%2==0)p+=a[i];
      if(i%2!=0)q+=a[i];
    }
    cout<<max(p,q)<<endl;
    return 0;
  }
  vl zero(n/2+1);
  vl one(n/2);
  zero[0]=a[0];
  one[0]=a[1];
  rep(i,n){
    if(i==0||i==1)continue;
    if(i%2==0)zero[i/2]=a[i]+zero[i/2-1];
    else one[i/2]=a[i]+one[i/2-1];
  }
  //rep(i,zero.size())cout<<zero[i]<<endl;
  //rep(i,one.size())cout<<one[i]<<endl;
  ll ans=-1000000007LL*500000;
  rep(i,n/2){
    //cout<<zero[i]<<" "<<one[n/2-1]-one[i]<<endl;
    ans=max(ans,zero[i]+one[n/2-1]-one[i]);
  }
  ll ans3=0;
  rep(i,n/2)ans+=a[i];
  reverse(a.begin(),a.end());
  vl zero2(n/2+1);
  vl one2(n/2);
  zero2[0]=a[0];
  one2[0]=a[1];
  rep(i,n){
    if(i==0||i==1)continue;
    if(i%2==0)zero2[i/2]=a[i]+zero2[i/2-1];
    else one2[i/2]=a[i]+one2[i/2-1];
  }
  rep(i,n/2){
    //cout<<zero[i]<<" "<<one[n/2-1]-one[i]<<endl;
    ans=max(ans,zero2[i]+one2[n/2-1]-one2[i]);
  }
  rep(i,n/2+1){
    for(ll j=i+1;j<=n/2-2;j++){
      ans=max(ans,zero[i]+one[j]-one[i]+zero[n/2]-zero[j+1]);
    }
  }
  cout<<ans<<endl;
}
    