import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
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[1] = -1;
for(int i = 3; i<=n; ++i){
dp
[i
] = dp
[i
] + Math.
max(dp
[i
-2], dp
[i
-3]); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludCBuOwoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCW4gPSBpbi5uZXh0SW50KCk7CgkJaW50W10gZHAgPSBuZXcgaW50W24gKyAxXTsKCQlmb3IoaW50IGkgPSAxOyBpIDw9IG47ICsraSl7CgkJCWRwW2ldID0gaW4ubmV4dEludCgpOwoJCX0KCQlkcFsxXSA9IC0xOwoJCWZvcihpbnQgaSA9IDM7IGk8PW47ICsraSl7CgkJCWRwW2ldID0gZHBbaV0gKyBNYXRoLm1heChkcFtpLTJdLCBkcFtpLTNdKTsKCQl9CgkJU3lzdGVtLm91dC5wcmludGxuKGRwW25dKTsKCX0KfQ==