#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010

ll n,a[M];
ll dp[M][2];
ll f(ll i,ll ok){
	if(i>=n)return 0;
	if(dp[i][ok]!=-1)return dp[i][ok];
	ll ans=f(i+2,ok)+a[i];
	if(ok)ans=max(ans,f(i+3,!ok)+a[i]);
	return dp[i][ok]=ans;
}
ll dp1[M][3][2];
ll f(ll i,ll f1,ll f2){
	if(i>=n){
		if(f1==2 and !f2)return 0;
		if(f1<2 and f2)return 0;
		return -1*inf;
	}
	if(dp1[i][f1][f2]!=-1)return dp1[i][f1][f2];
	ll ans=f(i+2,f1,f2)+a[i];
	if(f1)ans=max(ans,f(i+3,f1-1,f2)+a[i]);
	if(f2)ans=max(ans,f(i+4,f1,!f2)+a[i]);
	return dp1[i][f1][f2]=ans;
}
int main(){
	IOS;
	tihs;
	
	memset(dp,-1,sizeof(dp));
	memset(dp1,-1,sizeof(dp1));

	cin>>n;
	rep(i,0,n)cin>>a[i];
	ll ans=0,i=1;
	while(i<n)ans+=a[i],i+=2;
	if(n%2==0){
		cout<<max(ans,f(0,1));
		return 0;
	}
	ll sum=0;i=2;
	while(i<n)sum+=a[i],i+=2;
	ans=max(ans,sum);
	ans=max(ans,f(1,1));
	cout<<max(ans,f(0,2,1));
	return 0;
}