import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.typecons;
alias Pair = Tuple!(size_t, bool);
void main()
{
    immutable n = readln.chomp.to!size_t,
    a = readln.chomp.split.to!(long[]);
    // dp[i, k, 0] := max sum of k elements < i
    // dp[i, k, 1] := max sum of k-1 elements < i and a_i
    auto dp = new long[Pair][n];
    dp[0][Pair(size_t(0), false)] = 0;
    dp[0][Pair(size_t(1), true)] = a[0];
    foreach (i; 1..n)
    {
        foreach (kvp; dp[i-1].byKeyValue)
        {
            immutable
                k = kvp.key[0],
                f = kvp.key[1],
                v = kvp.value;
            if (k < n/2 - (n-i-f+1)/2)
                continue;
            if (auto p = Pair(k, false) in dp[i])
                dp[i][Pair(k, false)] = (*p).max(v);
            else
                dp[i][Pair(k, false)] = v;
            if (!f)
                dp[i][Pair(k+1, true)] = v + a[i];
        }
        debug stderr.writeln(dp[i]);
    }
    max(dp[n-1][Pair(n/2, true)], dp[n-1][Pair(n/2, false)]).writeln;
}
