#include<cstdio>
#include<cstdlib>
int main(void) {
	int N, i, b[3];	
	scanf("%d", &N);
	int *a = (int *)calloc(N, sizeof(int));
	for (i = 0; i < N; i++) {
		scanf("%d", a[i]);
	}
	b[0] = a[1];
	b[1] = a[0] + a[2];
	b[2] = a[0];
	for (i = 0; i < N; i++) {

		if (b[0] > b[1]) {
			b[2] = b[0] + a[i + 4];
			b[1] = b[2];
			b[0] = b[1];
		}
		else {
			b[2] = b[1];
			b[0] = b[1];
			b[1] = b[1];
		}
	}
	printf("%d", b[2]);
	return 0;
}