#include #include using namespace std; int n; int v[1000]; int dp[1000]; int main() { cin >> n; for (int i = 0; i> v[i]; } if (n == 1) { cout << v[0] << endl; return 0; } else if (n == 2) { cout << max(v[0], v[1]) << endl; return 0; } else if (n == 3) { cout << max(v[0] + v[2], v[1]) << endl; return 0; } else { dp[n - 3] = v[n - 3] + v[n - 1]; dp[n - 2] = v[n - 2]; dp[n - 1] = v[n - 1]; for (int i = n - 4; i >= 0; i--) { dp[i] = max(dp[i + 2], dp[i + 3]) + v[i]; } cout << max(dp[0], dp[1]) << endl; return 0; } }