#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

int odd_sum[200010]; // 奇数項の和
int even_sum[200010]; // 偶数項の和
int rui_mx[200010], rui_rev_mx[200010];

int N;
signed main()
{
	cin >> N;
	vi A(N+2);
	rep1(i,N)cin>>A[i];

	for (int i = 1; i <= N; i+=2)  {
		odd_sum[i] = A[i];
		if (i - 2 >= 0) {
			odd_sum[i] += odd_sum[i - 2];
			odd_sum[i - 1] = odd_sum[i - 2];
		}
	}

	for (int i = 2; i <= N; i+=2)  {
		even_sum[i] = A[i];
		if (i - 2 >= 0) {
			even_sum[i] += even_sum[i - 2];
			even_sum[i - 1] = even_sum[i - 2];
		}
	}

	if (N % 2 == 0) {
		int mx = odd_sum[N - 1];
		chmax(mx, even_sum[N]);
		//1hajimari
		for (int i = 1; i + 3 <= N; i += 2) { // iで2飛ばす
			if (i + 3 <= N) chmax(mx, odd_sum[i] + even_sum[N] - even_sum[i + 2]);
		}
		cout<<mx<<endl;
	} else { // N is od
		int mx = odd_sum[N] - odd_sum[1]; // 3 から始まる
		
		// 2始まり
		chmax(mx, even_sum[N - 1]);
		for (int i = 2; i+3 <= N; i += 2) { // iで2飛ばす
			if (i + 3 <= N) chmax(mx, even_sum[i] + odd_sum[N] - odd_sum[i + 1]);
		}

		// 1始まり
		chmax(mx, odd_sum[N - 2]);
		for (int i = 1; i +4<= N; i += 2) { // iで1度だけ3飛ばす
			chmax(mx, odd_sum[i] + odd_sum[N] - odd_sum[i + 2]);
		}
		// 1で始まって2 飛ばしを2回する
		// 前処理
		for (int i = 4; i <= N - 3; i += 2) {
			rui_mx[i] = odd_sum[i - 3];
			chmax(rui_mx[i], rui_mx[i - 2]);
		}
		for (int i = N - 3; i >= 1; i -= 2) {
			rui_rev_mx[i] = odd_sum[i + 3] - odd_sum[i];
			chmax(rui_rev_mx[i], rui_rev_mx[i + 2]);
		}

		for (int i = 4; i <= N; i += 2) {
			chmax(mx, rui_mx[i] + A[i] + rui_rev_mx[i]);
		}

		cout << mx << endl;
	}
}


