#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
constexpr int inf = 1000000010;
constexpr long long INF = 1000000000000000010;
constexpr long double eps = 1e-12;
constexpr long double pi = 3.141592653589793238;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  long long even = 0, odd = 0;
  for (int i = 0; i < n - 1; i += 2) even += a[i];
  for (int i = 1; i < n - 1; i += 2) odd += a[i];
  long long ans = 0;
  for (long long i = 0; i < (n); i++) {
    int pre = i - 1;
    if (pre < 0) pre += n;
    int nxt = pre - 1;
    if (nxt < 0) nxt += n;
    if (i & 1) {
      chmax(ans, odd + max(a[pre], a[nxt]));
      odd -= a[i];
      odd += a[pre];
    } else {
      chmax(ans, even + max(a[pre], a[nxt]));
      even -= a[i];
      even += a[pre];
    }
  }
  cout << ans << '\n';
}
