#include #include #include using namespace std; int n; int tastes[1002]; int dp[1002][2]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> tastes[i]; memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) { dp[i + 1][0] += max(dp[i][0], dp[i][1]); dp[i + 1][1] += dp[i][0] + tastes[i]; } cout << max(dp[n][0], dp[n][1]) << endl; }