#include <stdio.h>

long max(long a, long b) {
    if (a > b)
        return a;
    else
        return b;
}

long solve_sub(int a[], long pos) {
    static long memo[2 * 100000];
    static int flag[2 * 100000];

    if (flag[pos]) {
        return memo[pos];
    }

    long answer;
    if (pos == 0) {
        answer = a[pos];
    }
    else {
        answer = a[pos] + solve_sub(a, pos - 2);
    }

    memo[pos] = answer;
    flag[pos] = 1;
    return answer;
}

long solve(int a[], long pos) {
    static long memo[2 * 100000];
    static int flag[2 * 100000];

    if (flag[pos]) {
        //fprintf(stderr, "[pos=%ld,return=%ld](memo)\n", pos, memo[pos]);
        return memo[pos];
    }
 
    long answer;
    if (pos == 1) {
        answer = max(a[0], a[1]);
    }
    else if (pos == 2) {
        answer = max(max(a[0], a[1]), a[2]);
    }
    else if (pos % 2 == 1) {
        long tmp1 = a[pos] + solve(a, pos - 2);
        long tmp2 = solve_sub(a, pos - 1);
        answer = max(tmp1, tmp2);
    }
    else {
        long tmp1 = a[pos] + solve(a, pos - 2); //posにある整数を選ぶ場合
        long tmp2 = solve(a, pos - 1);     //posにある整数を選ばない場合
        answer = max(tmp1, tmp2);
    }

    memo[pos] = answer;
    flag[pos] = 1;
    //fprintf(stderr, "[pos=%ld,return=%ld]\n", pos, answer);
    return answer;
}

int main(void) {
    int n;
    int a[2 * 100000];

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    printf("%ld\n", solve(a, n - 1));
    return 0;
}
