#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[200009],dp[200009],i,j,k[200009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; i<=a; i++) cin>>f[i];
  for(i=a; i>=1; i--) k[i]=k[i+2]+f[i];
	for(i=a; i>=1; i--){
		if((a-i+1)%2==0){
			dp[i]=max(f[i]+dp[i+2],k[i+1]);
		}else{
			dp[i]=max(f[i+1]+dp[i+3],f[i]+dp[i+2]);
          if(dp[i]<k[i+3]) dp[i]=k[i+3];
		}
	}
  /*for(i=a; i>=a-7; i--){
    cout<<i<<" "<<dp[i]<<endl;
  }*/
	cout<<dp[1];
	return 0;
}