#include <iostream>
using namespace std;
typedef long long int ll;
int main() {
// your code goes here
ll n;
ll a[n+1];
cin>>n;
ll i=1;
while(i<=n)
{
cin>>a[i];
i++;
}
ll dp[n+1]={0};
ll k=0;
dp[1]=max(a[1],k);
dp[2]=max(a[2],max(a[1],k));
i=3;
while(i<=n)
{
dp[i]=max((a[i]+dp[i-2]),(dp[i-1]));
i++;
}
cout<<dp[n];
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBpbnQgbGw7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWxsIG47CglsbCBhW24rMV07CgljaW4+Pm47CglsbCBpPTE7Cgl3aGlsZShpPD1uKQoJIHsKCSAJY2luPj5hW2ldOwoJIAlpKys7CgkgfQoJIAoJIGxsIGRwW24rMV09ezB9OwoJIGxsIGs9MDsKCSBkcFsxXT1tYXgoYVsxXSxrKTsKCSBkcFsyXT1tYXgoYVsyXSxtYXgoYVsxXSxrKSk7CiAgICAKICAgICBpPTM7CiAgICAgd2hpbGUoaTw9bikKICAgICAgewogICAgICAJZHBbaV09bWF4KChhW2ldK2RwW2ktMl0pLChkcFtpLTFdKSk7CiAgICAgIAlpKys7CiAgICAgIH0KICAgICAgCiAgICAgIGNvdXQ8PGRwW25dOwogICAgCQoJcmV0dXJuIDA7Cn0=