#include<bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int MAX_N = 2e5 + 5;
const ll INF = 1e18;

int n, a[MAX_N];
ll dp[MAX_N][4];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	if (n % 2 == 0) {
		ll sum0 = 0, sum1 = 0;
		for (int i = 1; i <= n; ++i) {
			if (i % 2 == 0) sum0 += a[i];
			else sum1 += a[i];
		}
		cout << max(sum0, sum1) << "\n";
		return 0;
	}
	ll ans = -INF;
	for (int s = 1; s <= 3; ++s) {
		for (int i = 1; i <= n + 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				dp[i][j] = -INF;
			}
		}
		dp[s][0] = a[s];
		for (int i = s; i <= n; ++i) {
			dp[i][0] = dp[i - 2][0] + a[i];
			dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i];
			dp[i][2] = max(dp[i - 2][2], dp[i - 3][1]) + a[i];
			dp[i][1] = max(dp[i][1], dp[i][0]);
			dp[i][2] = max(dp[i][2], dp[i][1]);
		}
		ans = max(ans, dp[s + n - 3][0]);
		ans = max(ans, dp[s + n - 2][1]);
		ans = max(ans, dp[s + n - 1][2]);
	}
	cout << ans << "\n";
	return 0;
}