#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const ll MMM = -1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i=0; i<n; i++) cin >> a[i];
	int m = n/2;
	if (n&1) {
		ll ans = MMM;
		vector<ll> suff(m+1), pref(m+1), best_suff(m+1);
		// both end case
		for (int i=0; i<m; i++) {
			pref[i+1] = pref[i] + a[2*i];
		}
		for (int i=m-1; i>=0; i--) {
			suff[i] = suff[i+1] + a[2*i+2];
		}
		// single 3-jump
		for (int i=0; i<=m; i++) {
			ans = max(ans, pref[i] + suff[i]);
		}
		
		// double 2-jump
		for (int i=m-1; i>=0; i--) {
//			best_suff[i] = max(best_suff[i+1] + a[i*2+1], suff[i+1] + a[i*2+1]);
			best_suff[i] = max(best_suff[i+1], suff[i+1]) + a[i*2+1];
		}
		
		bool dbg = false;
		if (dbg) {
			cout << "PREF "; for (ll x : pref) cout << x << ' '; cout << '\n';
			cout << "SUFF "; for (ll x : suff) cout << x << ' '; cout << '\n';
			cout << "BEST "; for (ll x : best_suff) cout << x << ' '; cout << '\n';
		}
		
		ll best_pref = 0;
		ans = max(ans, best_suff[0]);
		for (int i=0; i<m; i++) {
			best_pref = max(best_pref, pref[i]) + a[i*2+1];
			ans = max(ans, best_pref + best_suff[i+1]);
		}
//		ans = max(ans, max(best_pref, pref[
		
		// one end case
		// should have covered by double 2-jump
		
		// neither end case
		ll tmp = 0;
		for (int i=0, idx=1; i<m; i++, idx+=2) tmp += a[idx];
		ans = max(ans, tmp);
		cout << ans;
	}
	else {
		vector<ll> suff(m+1);
		for (int i=m-1; i>=0; i--) {
			suff[i] = suff[i+1] + a[2*i+1];
		}
		ll ans = suff[0];
		ll pref = 0;
		for (int i=0; i<m; i++) {
			pref += a[i*2];
			ans = max(ans, pref + suff[i+1]);
		}
		cout << ans;
	}
}
#include <iostream>
using namespace std;
const long long OO = (long long) 1e18;
 
const int N = 200008;
int n;
long long a[N];
 
long long dp[N][3];
// dp[i][j] is maximum possible sum choosing (i+1-j)/2 elements from first i
// elements. This is NOT a floor! So half the dp elements will be impossible
// solely because it's impossible to choose half an element.
 
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
 
	dp[0][0] = -OO;
	dp[0][1] = 0;
	dp[0][2] = -OO;
	dp[1][0] = a[0];
	dp[1][1] = -OO;
	dp[1][2] = 0;
 
	for (int i = 2; i <= n; i++) {
		// note that we are computing dp[i] using a[i-1] and dp[i-1]
		for (int j = 0; j < 3; j++) {
			// take a[i-1]
			dp[i][j] = dp[i-2][j] + a[i-1];
 
			if (j) {
				// we have slack; don't take a[i-1]
				dp[i][j] = max(dp[i][j], dp[i-1][j-1]);
			}
		}
	}
 
	cout << dp[n][n % 2 == 0 ? 1 : 2];
}