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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;

const Int INF = 1e18;


int main() {
    Int N;
    cin >> N;
    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    vector<Int> dp0(N, -INF), dp1(N, -INF);

    dp0[0] = 0;
    dp1[0] = A[0];
    dp0[1] = max(A[0], A[1]);

    for(int i = 2; i<N; i++) {
        if (i % 2 == 1) {
            dp0[i] = max(dp1[i-1], A[i]+dp0[i-2]);
        }
        else {
            dp0[i] = max(dp0[i-1], A[i] + dp0[i-2]);
            dp1[i] = A[i] + dp1[i-2];
        }
    }

    cout << dp0[N-1] << endl;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,cur;
    cin >> n;
    long long ans = 0;
    cin >> cur;
    long long tot[3] = { 0,0,cur };
    for (int i = 2; i <= n; i++) {
        cin >> cur;
        if (i % 2) {
            tot[1] = max(tot[1], tot[2]);
            tot[0] += cur;
            tot[2] += cur;
        }
        else {
            tot[0] = max(tot[0], tot[1]);
            tot[1] += cur;
        }
    }
    cout << (n % 2 ? max(tot[0], tot[1]) : max(tot[1], tot[2]));
}