#include <stdio.h>
#include <inttypes.h>

#define INF INT64_C(77777777777777777)

int N;
int64_t A[271828];

int64_t memo[271828][3];
char valid[271828][3];

int64_t search(int pos, int skip) {
	int64_t answer = -INF;
	int64_t candidate;
	if (pos >= N) return (skip <= 1) ? 0 : -INF;
	if (valid[pos][skip]) return memo[pos][skip];

	/* 選ぶ */
	candidate = search(pos + 2, skip) + A[pos];
	if (candidate > answer) answer = candidate;
	/* 選ばない */
	if (skip > 0) {
		candidate = search(pos + 1, skip - 1);
		if (candidate > answer) answer = candidate;
	}

	memo[pos][skip] = answer;
	valid[pos][skip] = 1;
	return answer;
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	printf("%" PRId64 "\n", search(0, N % 2 == 0 ? 1 : 2));
	return 0;
}
