#include <stdio.h>

long max(long a, long b) {
  if (a >= b) {
    return a;
  } else {
    return b;
  }
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long dp0[n/2][2],dp1[n/2][2];
  dp0[0][0] = 0;
  dp0[0][1] = a[0];
  dp1[0][0] = -10000000000;
  dp1[0][1] = a[1];
  for (long i = 1; i < n/2; i++) {
    dp0[i][0] = dp0[i-1][0]+a[i*2];
    dp0[i][0] = max(dp0[i][0],max(dp0[i-1][1],dp1[i-1][1]));
    dp0[i][1] = dp0[i-1][1]+a[i*2];
    dp1[i][0] = max(dp0[i-1][0],dp1[i-1][0])+a[i*2+1];
    dp1[i][1] = max(dp0[i-1][1],dp1[i-1][1])+a[i*2+1];
  }
  long ans;
  if (n%2 == 0) {
    ans = max(dp0[n/2-1][1],dp1[n/2-1][1]);
  } else {
    ans = dp0[n/2-1][0]+a[n-1];
    ans = max(ans,max(dp0[n/2-1][1],dp1[n/2-1][1]));
  }
  printf("%ld\n", ans);

  return 0;
}
