#include <bits/stdc++.h>
#define loop(times) for(int i=0;i<(times);i++)

using namespace std;

int main() {
    while(1<2){
    int n;
    long long max;
    cin>>n;
    if(n==0)break;
    int a[n];
    int s[n];

    loop(n)cin>>a[i];
    max=a[0];
    s[0]=a[0];
        
    loop(n)s[i+1]=s[i]+a[i+1];
    for(int k=0;k<n;k++){
     loop(n-k){
         if(max<=s[k+i]-s[k-1])max=s[k+i]-s[k-1];   
    }
    }
    cout<<max<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=2e5+50;
vec l(N),r(N);
vec a(N);

ll cal(ll x) {
  if(x<3) {
    return 0;
  }
  return max({l[x-1],r[x-1],cal(x-2)+a[x]});
}

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) cin >> a[i];
  for(ll i=2;i<=n;i+=2) {
    l[i]=l[i-2]+a[i-1];
    r[i]=max(r[i-2],l[i-2])+a[i];
  }
  if(n%2) {
    cout << cal(n) << endl;
  }
  else {
    cout << max(l[n],r[n]) << endl;
  }
}