import std;

long calcEven(int[] a) {
    assert(a.length % 2 == 0);

    long sum1 = 0;
    long sum2 = 0;
    for (int i = 0; i < a.length; i += 2) {
        sum1 += a[i];
        sum2 += a[i+1];
    }
    return max(sum1, sum2);
}

long calc(int[] a) {
//    if (a.length % 2 == 0) return calcEven(a);

    alias Key = Tuple!(int, int);

    long ans = long.min;
    long rec(int p, int rest, ref long[Key] memo) {
        if (p >= a.length) {
            return 0;
        }

        if (Key(p, rest) in memo) {
            long m = memo[Key(p, rest)];
            return m;
        }

        long x = rec(p + 2, rest, memo) + a[p];
        if (rest > 0) {
            x = max(x, rec(p + 1, rest - 1, memo));
        }
        return memo[Key(p, rest)] = x;
    }

    long[Key] memo;
    return rec(0, a.length % 2 == 0 ? 1 : 2, memo);

}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
