#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vvl dp(n+1,vl(3,-linf));
	dp[0][0] = a[0];
	dp[1][1] = a[1];
	dp[2][2] = a[2];
	REP(i,2,n){
		chmax(dp[i][0],dp[i-2][0] + a[i]);
		if(i > 2){
			chmax(dp[i][1],dp[i-2][1] + a[i]);
			chmax(dp[i][1],dp[i-3][0] + a[i]);
		}
		if(i > 3){
			chmax(dp[i][2],dp[i-2][2] + a[i]);
			chmax(dp[i][2],dp[i-3][1] + a[i]);
			chmax(dp[i][2],dp[i-4][0] + a[i]);
		}
	}
	ll ans;
	if(n & 1) ans = max({dp[n-3][0],dp[n-2][1],dp[n-1][2]});
	else ans = max(dp[n-2][0],dp[n-1][1]);
	cout << ans << endl;
}
