#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

ll dp[201000][3][2]={};

int main(){
   int n; cin>>n;
   vector<int> a(n); rep(i,0,n)cin>>a[i];
   if(n&1){
      rep(i,0,n+1)rep(j,0,3)rep(k,0,2)dp[i][j][k]=-INF;
      rep(j,0,3)dp[0][j][1]=0;
      rep(i,0,n)rep(j,0,3)rep(k,0,2){
         chmax(dp[i+1][j][k^1],dp[i][j][k]+(k?a[i]:0));
         if(j!=2)chmax(dp[i+1][j+1][k],dp[i][j][k]);
      }
      ll res=0; rep(k,0,2)chmax(res,dp[n][2][k]);
      printf("%lld\n",res);
   }
   else{
      vector<ll> lb(n+1),rb(n+1);
      rep(i,0,n)lb[i+1]=lb[i]+(i%2==0?a[i]:0);
      rrep(i,n,0)rb[i-1]=rb[i]+((n-i)%2==0?a[i-1]:0);
      ll res=0;
      rep(i,0,n)if(i%2==0){
         chmax(res,lb[i]+rb[i]);
      } printf("%lld\n",res);
   }
   return 0;
}