#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("stdin","r",stdin);
freopen("stdout","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+CmxvbmcgbG9uZyBuLGFbMTAwMDA5XSxpLGRbMTAwMDA5XTsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKe2lvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwpjaW4udGllKDApO2NvdXQudGllKDApOwpmcmVvcGVuKCJzdGRpbiIsInIiLHN0ZGluKTsKZnJlb3Blbigic3Rkb3V0IiwidyIsc3Rkb3V0KTsKY2luPj5uOwpmb3IoaT0xO2k8PW47aSsrKQogICAgY2luPj5hW2ldOwpkWzFdPWFbMV07CmRbMl09YVsyXTsKZFszXT1tYXgoYVsxXSthWzNdLGFbMl0pOwpmb3IoaT00O2k8PW47aSsrKTsKZFtpXT1tYXgoZFtpLTFdLGRbaS0yXSthW2ldKTsKICAgIGNvdXQgPDxtYXgoZFtuXSxkW24tMV0pOwogICAgcmV0dXJuIDA7Cn0KICAgIAogIA==