#include <stdio.h>
long long max(long long x, long long y) {
	long long z;
	z = x;
	if (y > x)z = y;
	return z;
}
long long n, w;
long long a[200000];
long long dp[2][2];
long long e[2][2];
int main() {
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	for (long long i = 0; i < n; i++) {
		e[0][0] = dp[0][0];
		e[0][1] = dp[0][1];
		e[1][0] = dp[1][0];
		e[1][1] = dp[1][1];
		if (i % 2 == 0) {
			dp[0][0] = max(e[0][1], e[1][1]);
			dp[1][1] = e[0][1] + a[i];
			dp[1][0] = e[0][0] + a[i];
			dp[0][1] = -1000000000;
			dp[0][1] *= 1000000;
		}
		else {
			dp[0][0] = max(e[0][0], e[1][0]);
			dp[0][1] = max(e[0][1], e[1][1]);
			dp[1][1] = e[0][0] + a[i];
			dp[1][0] = -1000000000;
			dp[1][0] *= 1000000;
		}
	}
	if (n % 2) {
		printf("%lld\n", max(dp[0][0], dp[1][0]));
	}
	else printf("%lld\n", max(dp[0][1], dp[1][1]));
}
