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

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto K = N % 2 ? 2 : 1;
    auto dp = new long[][](N + 5, K + 1);
    foreach (ref d; dp) d[] = -(1L << 59);
    dp[0][0] = 0;
    dp[1][1] = 0;
    if (K == 2) dp[2][2] = 0;

    foreach (i; 0..N) foreach (k; 0..K+1) {
        dp[i + 2][k] = max(dp[i + 2][k], dp[i][k] + A[i]);
        if (k + 1 <= K) dp[i + 3][k + 1] = max(dp[i + 3][k + 1], dp[i][k] + A[i]);
        if (k + 2 <= K) dp[i + 4][k + 2] = max(dp[i + 4][k + 2], dp[i][k] + A[i]);
    }

    long ans = -(1L << 59);

    foreach (i; N..N+5) ans = max(ans, dp[i][K]);
    ans.writeln;
}