#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<long long> k;
long long memo[200010][2];
long long sol(long long pos, long long buco) {
  if (pos >= k.size()) {
    if (buco) return 0;
    return 1e18;
  }
  if (memo[pos][buco] != -1) return memo[pos][buco];
  long long mi = 1e18;
  mi = min(mi, sol(pos + 2, buco) + k[pos]);
  if (buco == 0) mi = min(mi, sol(pos + 3, 1) + k[pos]);
  return memo[pos][buco] = mi;
}
void solve() {
  long long N;
  cin >> N;
  for (long long i = 0; i < N + 5; i++) {
    memo[i][0] = memo[i][1] = -1;
  }
  k.resize(N);
  long long tot = 0;
  for (long long &i : k) {
    cin >> i;
    tot += i;
  }
  cout << tot - min({sol(0, 0), sol(1, 0), sol(2, 1)});
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long T = 1;
  while (T--) solve();
}
