#include <iostream>
using namespace std;
int main() {
int n, i;
cin >> n;
int *dp;
dp = new int [n+1];
for(i = 1; i<=n; ++i){
cin >> dp[i];
}
dp[0] = 0;
dp[1] = 0;
for(int i = 2; i<=n; ++i){
if(i - 3 >= 0) dp[i] = dp[i] + max(dp[i-2], dp[i-3]);
}
cout << dp[n];
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbiwgaTsKCWNpbiA+PiBuOwoJaW50ICpkcDsKCWRwID0gbmV3IGludCBbbisxXTsKCWZvcihpID0gMTsgaTw9bjsgKytpKXsKCQljaW4gPj4gZHBbaV07Cgl9CglkcFswXSA9IDA7CglkcFsxXSA9IDA7Cglmb3IoaW50IGkgPSAyOyBpPD1uOyArK2kpewoJCWlmKGkgLSAzID49IDApIGRwW2ldID0gZHBbaV0gKyBtYXgoZHBbaS0yXSwgZHBbaS0zXSk7Cgl9Cgljb3V0IDw8IGRwW25dOwoJcmV0dXJuIDA7Cn0=