#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define MOD 1000000007

long long int max(long long int a, long long int b) {
    return a>b?a:b;
}

long long int SeqSum(int a[], int n) {
    long long int sum_1 = 0, sum_2 = 0, dp[n];
    int i;
    dp[0] = 0;
    dp[1] = max(a[0], a[1]);
    dp[2] = max(dp[1], a[2]);
    for(i=3;i<n;i++) {
        if(i%2 == 0) {
            dp[i] = max(dp[i-2], dp[i-3])+a[i];
        }
        else {
            dp[i] = dp[i-2]+a[i];
        }
    }
    return dp[n-1];
}

int main() {
    int n, i, *a;
    long long int sum = 0;
    if(scanf("%d", &n)) {
        a = (int*)malloc(n*sizeof(int));
        for(i=0;i<n;i++) {
            scanf("%d", &a[i]);
        }
        printf("%lld", SeqSum(a, n));
    }
    return 0;
}