#include #include using namespace std; int deli[1000]; int memo[1000]; int N; int solve(int n) { if (n > N) return 0; if (memo[n] != -1) return memo[n]; return memo[n] = max(solve(n+1), solve(n+2) + deli[n]); } int main(void) { cin >> N; for (int i = 0; i < N; i++) { memo[i] = -1; cin >> deli[i]; } cout << solve(0) << endl; return 0; }