#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll Solve_g(vec x){
    ll N=x.size();
    ll M=N/2;
    vec a(M+1,0),b(M+1,0);
    rep(i,M) a.at(i+1)=a.at(i)+x.at(i*2);
    rep(i,M) b.at(i+1)=b.at(i)+x.at(N-1-(i*2));
    ll ret=a.at(M);
    rep(i,M) ret=max(ret,a.at(i)+b.at(M-i));
    return ret;
}

ll Solve_k(vec x){
    ll N=x.size();
    ll M=N/2;
    ll MIN=INF;
    vec a(N+2,0), b(N+2,0);
    for(int i=0;i<N;i+=2) {
        a.at(i+2)=a.at(i)+x.at(i);
        MIN=min(x.at(i),MIN);
    }
    for(int i=1;i<N;i+=2) {
        b.at(i+2)=b.at(i)+x.at(i);
    }
    ll SUM=a.at(N+1);
    ll ret=SUM-MIN;
    /*rep(i,N+2) cout<<a.at(i)<<' ';
    cout<<endl;
    rep(i,N+2) cout<<b.at(i)<<' ';
    cout<<endl;
    cout<<ret<<endl;*/
   for(int i=1;i<N;i+=2) for(int j=i;j<N;j+=2){
       ll UP=b.at(j+2)-b.at(i);
       ll DOWN=a.at(j+3)-a.at(i-1);
       ret=max(SUM+UP-DOWN,ret);
   }
   return ret;



}

int main(){
    ll N; cin>>N;
    vec x(N);
    rep(i,N) cin>>x.at(i);
    if(N%2==1) cout<<Solve_k(x)<<endl;
    else cout<<Solve_g(x)<<endl;
}