#include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n; cin >> n; vector v(n); rep(i, n) cin >> v[i]; vector dp(n, 0); dp[0] = v[0]; if (n > 1) { dp[1] = max(v[0], v[1]); for (int i = 2; i < n; i++) { dp[i] = max(dp[i - 1], dp[i - 2] + v[i]); } } cout << dp[n - 1] << "\n"; return 0; }