#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 200010, MOD = 998244353;

ll n, dp[N][3],a[N];

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}

int bb(int v1) {
	if (v1 % 2 == 0)return v1 / 2 - 1;
	else return v1 / 2;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	if (n % 2 == 0) {
		ll v1 = 0, v2 = 0;
		for (int i = 1; i <= n; i += 2)v1 += a[i];
		for (int i = 2; i <= n; i += 2)v2 += a[i];
		cout << max(v1, v2) << endl;
		return 0;
	}

	ll ans = INT16_MIN;
	for (int i = 0; i <= n; i++) {
		dp[i][0] = dp[i][1] = dp[i][2] = INT64_MIN;
	}
	dp[0][1] = 0;
	dp[1][2] = a[1];
	dp[2][1] = a[2];
	dp[3][1] = a[3];
	for (int i = 0; i <= n; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < 3; j++) {
				if (dp[i][j] == INT64_MIN)continue;
				int v1 = i / 2 + j - 1;
				if (v1 == n / 2)ans = max(ans, dp[i][j]);
				for (int i2 = i + 2; i2 <= n; i2++) {
					if (bb(i2) > v1 + 1)break;
					dp[i2][v1 + 2 - i2 / 2] = max(dp[i][j] + a[i2], dp[i2][v1 + 2 - i2 / 2]);
				}
			}
		}
		else {
			for (int j = 0; j < 3; j++) {
				if (dp[i][j] == INT64_MIN)continue;
				if (j == 0)continue;
				int v1 = i / 2 + j - 1;
				if (v1 == n / 2)ans = max(ans, dp[i][j]);
				for (int i2 = i + 2; i2 <= n; i2++) {
					if (bb(i2) > v1 + 1)break;
					dp[i2][v1 + 2 - i2 / 2] = max(dp[i][j] + a[i2], dp[i2][v1 + 2 - i2 / 2]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
