#include #include using namespace std; int dp[1010] = { 0 }; int V[1010] = { 0 }; int N; int max(int k) { if (k >= N) return 0; if (dp[k] != 0)return dp[k]; if (k == N-1) { dp[k] = V[N-1]; return V[N-1]; } int ans = max(V[k] + max(k + 2), V[k + 1] + max(k + 3)); dp[k] = ans; return ans; } int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> V[i]; } cout << max(0) << endl; return 0; }