#include <iostream>
#include <cstdio>

using namespace std;

const int N = 100005;

typedef long long LL;

int n, a[N], Lm[N], Rm[N];

LL L[N], R[N], f[N][2], g[N][2];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	if (n % 2 == 0) {
		LL v1 = 0, v2 = 0;
		for (int i = 1; i <= n; i += 2) {
			v1 += a[i];
			v2 += a[i + 1];
		}
		printf("%lld\n", max(v1, v2));
	} else {
		LL ans = 0;
		for (int i = 2; i <= n; i += 2) ans += a[i];
		LL v1 = 0;
		int v2 = 2e9;
		for (int i = 1; i <= n; i += 2) v1 += a[i], v2 = min(v2, a[i]);
		ans = max(ans, v1 - v2);
		L[1] = Lm[1] = a[1];
		for (int i = 2; i <= n; i++) {
			L[i] = L[i - 2] + a[i];
			if (i == 2) Lm[i] = a[i];
			else Lm[i] = min(Lm[i - 2], a[i]);
		}
		for (int i = n; i; i--) {
			R[i] = R[i + 2] + a[i];
			Rm[i] = a[i];
			if (i + 2 <= n) Rm[i] = min(Rm[i], Rm[i + 2]);
		}
		for (int i = 1; i + 3 <= n; i++) {
			ans = max(ans, L[i] + R[i + 3]);
		}
		f[2][1] = a[2];
		for (int i = 4; i <= n; i += 2) {
			f[i][1] = f[i - 2][1] + a[i];
			f[i][0] = max(L[i - 3] + a[i], f[i - 2][0] + a[i]);
		}
		g[n - 1][1] = a[n - 1];
		for (int i = n - 3; i; i -= 2) {
			g[i][1] = g[i + 2][1] + a[i];
			g[i][0] = max(R[i + 3] + a[i], g[i + 2][0] + a[i]);
		}
		for (int i = 2; i + 2 <= n; i++) {
			ans = max(ans, f[i][0] + g[i + 2][0]);
		}
		printf("%lld\n", ans);
	}
	return 0;
}