#include <bits/stdc++.h>
using namespace std;
mt19937 gene(233);
inline char GET_CHAR() {
  const int maxn = 131072;
  static char buf[maxn], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, maxn, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int getInt() {
  int res(0);
  char c = getchar();
  while (c < '0') c = getchar();
  while (c >= '0') {
    res = res * 10 + (c - '0');
    c = getchar();
  }
  return res;
}
inline long long fastpo(long long x, long long n, long long mod) {
  long long res(1);
  while (n) {
    if (n & 1) {
      res = res * (long long)x % mod;
    }
    x = x * (long long)x % mod;
    n /= 2;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline string itoa(int x, int width = 0) {
  string res;
  if (x == 0) res.push_back('0');
  while (x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while ((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
  fwrite(buf, 1, _bl, stdout);
  _bl = 0;
}
__inline void _putchar(char c) {
  if (_bl == _B) flush();
  buf[_bl++] = c;
}
inline void print(long long x, char c) {
  static char tmp[20];
  int l = 0;
  if (!x)
    tmp[l++] = '0';
  else {
    while (x) {
      tmp[l++] = x % 10 + '0';
      x /= 10;
    }
  }
  for (int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
  _putchar(c);
}
struct P {
  double x, y;
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
long long s[N];
int a[N];
int main() {
  int n;
  cin >> n;
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = a[i] + (i - 2 >= 0 ? s[i - 2] : 0);
    sum += a[i];
  }
  ans = sum;
  for (int i = 1; i <= n; i++) {
    long long tmp = s[i];
    if (i % 2 == 1) {
      if (i == n)
        tmp = tmp - s[1];
      else
        tmp = tmp + s[n - 1] - s[i + 1];
    } else {
      if (i == n - 1) {
      } else
        tmp = tmp + s[n] - s[i + 1];
    }
    ans = min(ans, tmp);
  }
  cout << sum - ans << endl;
}
