#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
        cin >> a[i];

    vector<ll> dp(n+1);
    dp[0] = 0;
    dp[1] = 0;

    ll accum = a[0];
    IFOR(i, 2, n){
        if(i % 2 == 0){
            dp[i] = max(dp[i-2] + a[i-1], accum);
        }
        else{
            accum += a[i-1];
            dp[i] = max(dp[i-2] + a[i-1], dp[i-1]);
        }
    }

    cout << dp[n] << endl;

    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;
typedef long long ll;

const int MAXN = 2e5 + 5;

const ll INF = 5e16;

int n;
int a[MAXN];

ll brute(int i, int qtt) {
	if (i > n) {
		if (qtt == n/2) return 0;
		else return -INF;
	}

	return max(a[i] + brute(i+2, qtt+1), brute(i+1, qtt));
}

ll memo[MAXN][5];
ll solve(int i, int duplo) {
	if (i > n) return duplo * -INF;

	ll& ret = memo[i][duplo];
	if (ret != -INF) return ret;

	ret = max(ret, a[i] + solve(i+2, duplo));
	if (duplo) ret = max(ret, solve(i+1, duplo-1));

	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	if (n <= 10) printf("%lld\n", brute(1, 0));
	else {
		for (int i = 1; i <= n; i++) for (int j = 0; j <= 4; j++)
			memo[i][j] = -INF;

		ll ans = -INF;
		if (n%2 == 0) {
			ans = solve(1, 1);
			ans = max(ans, solve(2, 0));
		} else {
			ans = solve(1, 2);
			ans = max(ans, solve(2, 1));
		}

		printf("%lld\n", ans);
	}
	
}