#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll dp[300000][20][2];
ll a[300000];

int main(){
	int n;cin>>n;
	rep(i,n)scanf("%lld",&a[i]);
	if(n%2==0){
		ll s1=0,s2=0;
		rep(i,n){
			if(i%2==0)s1+=a[i];
			s2+=a[i];
		}
		cout<<max(s1,s2-s1)<<endl;
		return 0;
	}
	rep(i,n+1)rep(j,20)rep(k,2){
		dp[i][j][k]=-INFL;
	}
	dp[0][10][0]=0;
	rep(i,n)rep(j,20)rep(k,2){
		if(dp[i][j][k]==-INFL)continue;
		if(k==0&&j+1<20){
			dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i][j][k]+a[i]);
		}
		if(j-1>=0)dp[i+1][j-1][0]=max({dp[i+1][j-1][0],dp[i][j][k]});
	}
	cout<<max(dp[n][9][0],dp[n][9][1])<<endl;
}