#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <numeric>

using ll = long long;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int N; cin>>N;
    ll ans{};

    vector<ll> v(N);
    for (auto& e: v) cin>>e;
    using type = vector<pair<ll,ll>>;
    vector<type> dp(N);
    for (int i = 0; i < N; ++ i) {
        //  i/2   cnts...

        if (i <= 2) {
            pair<ll, ll> a{1, v[i]};
            dp[i] = vector<pair<ll,ll>> {a};
        }
        else {
            int few = (i+1)/2;
            pair<ll,ll> p{few, 0};
            // not choosing
            for (int j = i-2; j >= i-4 && j >= 0; -- j){
                for (auto& e : dp[j]){
                    if (e.first == few) {
                        p.second = max(p.second, e.second);
                    }
                }
            }
            // choosing
            for (int j = i-2; j >= i-4 && j >= 0; -- j){
                for (auto& e : dp[j]){
                    if (e.first == few-1) {
                        p.second = max(p.second, e.second + v[i]);
                    }
                }
            }
            dp[i] = type{p};
            if (p.first == N/2) ans = max(ans, p.second);
        }
    }
    cout<<ans<<endl;

    return 0;
}

