"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var n,a;
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  n = next();
  a = nexts(n);
  if(n & 1)return solveodd();
  return solveeven();
}
function solveeven(){
  var r = [0,0];
  for(var i = 0; i < n; i++)r[i&1] += a[i];
  return Math.max(...r);
}

function solveodd(){
  var dp = xArray(0,n+1,3,2);
  for(var i = 0; i < n; i++){
    dp[i+1][0][1] = dp[i][0][0] + a[i];
    dp[i+1][0][0] = dp[i][0][1];
    dp[i+1][1][0] = Math.max(dp[i][0][0], dp[i][1][1]);
    dp[i+1][1][1] = dp[i][1][0] + a[i];
    dp[i+1][2][0] = Math.max(dp[i][1][0], dp[i][2][1]);
    dp[i+1][2][1] = dp[i][2][0] + a[i];
  }
  return Math.max(dp[n][1][0], dp[n][2][1]);
}