/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
int n;
Scanner in
= new Scanner
( System .
in ) ; n = in.nextInt ( ) ;
int [ ] dp = new int [ n+ 1 ] ;
for ( int i = 1 ; i<= n; ++ i) {
dp[ i] = in.nextInt ( ) ;
}
dp[ 0 ] = 0 ;
dp[ 1 ] = 0 ;
for ( int i = 2 ; i<= n; ++ i) {
if ( i - 3 >= 0 )
dp
[ i
] = dp
[ i
] + Math .
max ( dp
[ i
- 2 ] , dp
[ i
- 3 ] ) ; }
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludCBuOwoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCW4gPSBpbi5uZXh0SW50KCk7CgkJaW50W10gZHAgPSBuZXcgaW50IFtuKzFdOwoJCWZvcihpbnQgaSA9IDE7IGk8PW47ICsraSl7CiAgICAgICAgCQlkcFtpXSA9IGluLm5leHRJbnQoKTsKCQl9CgkJZHBbMF0gPSAwOwoJCWRwWzFdID0gMDsKCQlmb3IoaW50IGkgPSAyOyBpPD1uOyArK2kpewogICAgCQlpZihpIC0gMyA+PSAwKQogICAgICAgIAkJZHBbaV0gPSBkcFtpXSArIE1hdGgubWF4KGRwW2ktMl0sIGRwW2ktM10pOwoJCX0KCQlTeXN0ZW0ub3V0LnByaW50KGRwW25dKTsKCX0KfQ==