#include <bits/stdc++.h>
using namespace std;
struct segtree {
  vector<long long> t;
  segtree(long long _n) { t.resize(4 * _n); }
  void update(long long id, long long l, long long r, long long pos,
              long long val) {
    if (l == r) {
      t[id] = val;
      return;
    }
    long long mid = (l + r) / 2;
    if (pos <= mid) {
      update(2 * id, l, mid, pos, val);
    } else {
      update(2 * id + 1, mid + 1, r, pos, val);
    }
    t[id] = t[2 * id] + t[2 * id + 1];
  }
  long long query(long long id, long long l, long long r, long long lq,
                  long long rq) {
    if (lq > r || l > rq) return 0;
    if (lq <= l && r <= rq) return t[id];
    long long mid = (l + r) / 2;
    long long L = query(2 * id, l, mid, lq, rq);
    long long R = query(2 * id + 1, mid + 1, r, lq, rq);
    return L + R;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (auto& a : A) cin >> a;
  segtree t1(N), t2(N);
  for (long long i = 0; i < N; i++) {
    if (i % 2) {
      t1.update(1, 0, N - 1, i, A[i]);
    } else {
      t2.update(1, 0, N - 1, i, A[i]);
    }
  }
  long long best = A[0];
  for (long long i = 0; i + 1 < N; i++) {
    long long foo = A[i] + A[i + 1];
    long long from = i + 3, to = N - 1;
    if (to >= from) {
      if (i % 2) {
        foo += t2.query(1, 0, N - 1, from, to);
      } else {
        foo += t1.query(1, 0, N - 1, from, to);
      }
    }
    from = 0;
    to = i - 2;
    if (to >= from) {
      long long z = to - from + 1;
      if (z % 2) {
        foo += t2.query(1, 0, N - 1, from, to);
      } else {
        foo += t1.query(1, 0, N - 1, from, to);
      }
    }
    best = max(best, foo);
  }
  long long foo = 0;
  if (N > 1) {
    foo = A[0] + A[N - 1];
    for (long long i = 2; i <= N - 3; i += 2) foo += A[i];
  }
  cout << max(best, foo) << '\n';
  return 0;
}
