#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; int main() { int dp[1001]; int n; cin >> n; vector V(n); for(auto&& x : V) { cin >> x; } if(n == 1) { cout << V.at(0) << endl; return 0; } dp[0] = V.at(0); dp[1] = max(dp[0],V.at(1)); for(int i = 2; i < n; ++i) { dp[i] = max(dp[i-1],dp[i-2] + V.at(i)); } cout << dp[n-1] << endl; }