#include <bits/stdc++.h>
long long n,a[100009],i,d[100009];
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
freopen("wood.inp","r",stdin);
freopen("wood.out","w",stdout);
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
d[1]=a[1];
d[2]=a[2];
d[3]=max(a[1]+a[3],a[2]);
for(i=4;i<=n;i++);
d[i]=max(d[i-1],d[i-2]+a[i]);
cout <<max(d[n],d[n-1]);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CmxvbmcgbG9uZyBuLGFbMTAwMDA5XSxpLGRbMTAwMDA5XTsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKe2lvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwpjaW4udGllKDApO2NvdXQudGllKDApOwpmcmVvcGVuKCJ3b29kLmlucCIsInIiLHN0ZGluKTsKZnJlb3Blbigid29vZC5vdXQiLCJ3IixzdGRvdXQpOwpjaW4+Pm47CmZvcihpPTE7aTw9bjtpKyspCiAgICBjaW4+PmFbaV07CmRbMV09YVsxXTsKZFsyXT1hWzJdOwpkWzNdPW1heChhWzFdK2FbM10sYVsyXSk7CmZvcihpPTQ7aTw9bjtpKyspOwpkW2ldPW1heChkW2ktMV0sZFtpLTJdK2FbaV0pOwogICAgY291dCA8PG1heChkW25dLGRbbi0xXSk7CiAgICByZXR1cm4gMDsKfQoKICAgICAgCiAg