#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	vector<vector<ll>> dp(n/2, vector<ll>(n, -1e9+7));

	for(int j = 0; j < n; ++j) {
		if(j == 0) dp[0][j] = a[0];
		else {
			dp[0][j] = max(a[j], dp[0][j-1]);
		}
	}
	for(int i = 1; i < n/2; ++i){
		for(int j = i * 2; j < n; ++j) {
			if (j == i * 2) {
				dp[i][j] = dp[i-1][j-2] + a[j];
			}
			else {
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - 2] + a[j]);
			}
		}
	}

	cout << dp[n / 2 - 1][n - 1] << endl;

	return 0;
}
