#include #include #include #include #include #include #include using namespace std; #define FOR(i, s, e) for (int i = (s); i <= (e); i++) int n; int v[1010]; int dp[1010]; int main() { cin >> n; FOR(i,0,n - 1) cin >> v[i]; FOR(i,0,n - 1) { //eat if(i == 0) { dp[i + 1] = max(dp[i + 1],v[i]); } else if(i == 1) { dp[i + 1] = max(dp[i + 1],dp[i]); dp[i + 1] = max(dp[i + 1] , v[i]); } else { dp[i + 1] = max(dp[i + 1],dp[i]); dp[i + 1] = max(dp[i + 1],dp[i - 1] + v[i]); } } cout << dp[n] << endl; return 0; }