#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

int main(void) {
    int N;
    int i,cnt=0,len;
    char *buf;
    char *p;
    int64_t minA = 1000000000;
    int64_t *A;
    int64_t evenbef=0,evenaft = 0;
    int64_t oddbef=0,oddaft = 0;
    int64_t *peven,*podd;
    int64_t sum=0;
    int mincnt;

    buf = (char*)malloc(8);
    p = fgets(buf, 8, stdin);

    N = atoi(p);

    buf = (char*)realloc(buf, (11 * N)+2);
    A = (int64_t*)malloc(sizeof(int64_t) * N);

    p = fgets(buf, (11*N) + 2, stdin);

    peven = &evenbef;
    podd = &oddbef;
    for(i=0;;i++){
        if(buf[i] == ' '){
            buf[i] = '\0';
            A[cnt] = strtol(p,0,0);
            p = &buf[i+1];
        
            if(cnt % 2){
                (*podd) += A[cnt];
            } else {
                (*peven) += A[cnt];
            }
            if(minA > A[cnt]){
                minA = A[cnt];
                mincnt = cnt;
                evenbef += evenaft;
                oddbef += oddaft;
                evenaft = 0;
                oddaft = 0;
                peven = &evenaft;
                podd = &oddaft;
            }
            cnt++;
        } else if(buf[i] < '0' || buf[i] > '9') {
            len = i;
            break;
        }
    }
    A[cnt] = strtol(p,0,0);
    if(cnt % 2) {
        (*podd) += A[cnt];
    }else {
        (*peven) += A[cnt];
    }

    if((N % 2) == 0){
        if((evenbef + evenaft) > (oddbef + oddaft)) {
            printf("%ld\n", evenbef + evenaft);
        } else {
            printf("%ld\n", oddbef + oddaft);
        }
    } else {
        sum = (evenbef > oddbef ) ? evenbef : oddbef;
        sum += (evenaft > oddaft ) ? evenaft : oddaft;
        printf("%ld\n", sum);
    }
    free(buf);
    return 0;
}
