#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}


constexpr int ms = 1e5 + 13;
ll dp[ms][2];
ll v[ms];
ll padding = -MOD;
ll safe_min = padding * 1ll * ms;
int n;

ll solve(int cur_index, int remaining) {
    // se ja computamos
    if(dp[cur_index][remaining] != (safe_min - 13) ) return dp[cur_index][remaining];
    if(remaining == 0) return dp[cur_index][remaining] = 0;    
    if(cur_index >= n && remaining > 0) return padding;
    // agora tenho que escolher entre usar ou nao 
    ll ans = max( solve(cur_index + 1, remaining), solve(cur_index + 2, remaining - 1) + v[cur_index] );
    return dp[cur_index][remaining] = ans;
}
// End of template code!
int main() 
{
    buff();
    cin >> n;
    for(int i = 0; i < n + 11; ++i) dp[i][0] = dp[i][1] = (safe_min - 13);
    for(int i = 0; i < n; ++i) cin >> v[i]; 

    cout << solve(0, n / 2) << '\n';
    return 0;
}

