import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(long[]);

    auto dp = new long[][](N, 3);
    fillAll(dp, -infl);

    dp[N - 1][2] = a[N - 1];
    dp[N - 2][0] = max(a[N - 1], a[N - 2]);

    foreach_reverse (i ; 0 .. N - 2) {
        if ((N - i) % 2 == 0) {
            dp[i][0] = max(a[i] + dp[i + 2][0], 
                            a[i + 1] + (i + 3 < N ? dp[i + 3][2] : 0));
        }
        else {
            dp[i][1] = max(a[i] + dp[i + 2][1], 
                            a[i + 1] + (i + 3 < N ? dp[i + 3][0] : 0),
                            a[i + 2] + (i + 4 < N ? dp[i + 4][2] : 0));
        }
        dp[i][2] = a[i] + dp[i + 2][2];
    }

    debug {
        writefln("%(%s\n%)", dp);
    }

    long ans;

    if (N % 2 == 0) {
        ans = dp[0][0];
    }
    else {
        ans = dp[0][1];
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}
